| 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'
MC/DC100%1/1
shift() || 'default'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 8 | 70 | ▶ | die ref($self).": no such primitive '$new'" unless $self->has_primitive($new); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 17 | 0 | my $args = shift; | |||||||||||
| 18 | 0 | ▶ | die "usage: ${pkg}::new(\%args) or ${pkg}::new(\\%args)" unless ref($args) eq 'HASH'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 30 | 196 | return $_[0]->{primitive}; | |||||||||||
| 31 | } | ||||||||||||
| 32 | 8 | ▶ | if (@_ == 2) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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; | |||||||||||