blib/lib/Crypt/Sodium/XS/OO/Base.pm

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 5 / 10 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 4 totaltotal 71.7% 38 / 53 CC 7 SCAR 9.9
CC
7
Cov
76%
new
3.9
primitive
3.1
_set_primitive
3.0
CRAP 2.7
« blib/lib/Crypt/Sodium/XS/MemVault.pm ↑ Summary blib/lib/Crypt/Sodium/XS/Core.pm »
1 package Crypt::Sodium::XS::OO::Base;
2 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 70 ▶sub _set_primitive {
Subroutine _set_primitive: called CC=3 SCAR=11.0
6 70 my $self = shift;
7 70 ▶ my $new = shift || 'default';
Condition100%2/2
shift() || 'default'
l!l
691
MC/DC100%1/1
shift() || 'default'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
8 70 ▶ die ref($self).": no such primitive '$new'" unless $self->has_primitive($new);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_primitive($new) 0 70 70
9 70 $self->{primitive} = $new;
10 70 return $self;
11 }
12  
13 62 ▶sub new {
Subroutine new: called CC=3 SCAR=13.6
Pod undocumented
14 62 my $pkg = shift;
15 62 my %args;
16 62 ▶ if (@_ % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ % 2) { } 0 62 62
17 0 my $args = shift;
18 0 ▶ die "usage: ${pkg}::new(\%args) or ${pkg}::new(\\%args)" unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 0 0
19 0 %args = %$args;
20 }
21 else {
22 62 %args = @_;
23 }
24 62 my $obj = bless({}, $pkg);
25 62 return $obj->_set_primitive($args{primitive});
26 }
27  
28 204 ▶sub primitive {
Subroutine primitive: called CC=3 SCAR=11.3
Pod undocumented
29 204 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 196 8 204
30 196 return $_[0]->{primitive};
31 }
32 8 ▶ if (@_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) 8 0 8
33 8 return $_[0]->_set_primitive($_[1]);
34 }
35 0 die "usage: ->primitive([\$new_primitive])";
36 }
37  
38 # should not be called, to be implemented by subclass
39 0 ▶sub primitives { die "BUG: subclass missing primitives() method" }
Subroutine primitives: not called CC=1 SCAR=6.9
Pod undocumented
40  
41 70 ▶sub has_primitive { !!grep { $_ eq $_[1] } $_[0]->primitives }
Subroutine has_primitive: called CC=1 SCAR=0.0
Pod undocumented
42  
43 22 1;
« blib/lib/Crypt/Sodium/XS/MemVault.pm ↑ Summary blib/lib/Crypt/Sodium/XS/Core.pm »