Focus/Lens/Dynamic.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 8 / 8 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 67 / 67 CC 8 SCAR 13.7
CC
8
Cov
100%
_associated_lens
7.0
apply_lens
2.0
BEGIN
1.0
CRAP 3.9
« Focus/Lens/HashArray/Index.pm ↑ Summary Focus/LensTester.pm »
1 package Data::Focus::Lens::Dynamic;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use parent qw(Data::Focus::Lens);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 64 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
9 64 my ($class, $param) = @_;
10 64 return bless \$param, $class;
11 }
12  
13 67 ▶sub _associated_lens {
Subroutine _associated_lens: called CC=7 SCAR=19.5
14 67 my ($self, $target) = @_;
15 67 ▶ if(blessed($target) && $target->can("Lens")) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($target) and $target->can("Lens")) 7 60 67
Condition100%3/3
builtin::blessed($target) and $target->can("Lens")
!ll&&!rl&&r
5917
MC/DC100%2/2
builtin::blessed($target) and $target->can("Lens")
builtin::blessed($target) $target->can("Lens")
Truth table100%3/3
A and B
A= builtin::blessed($target)B= $target->can("Lens")
ABresult
0X0
100
111
16 7 my $assoc_lens = $target->Lens($$self);
17 6 ▶ if(! eval { $assoc_lens->isa("Data::Focus::Lens") }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $assoc_lens->isa("Data::Focus::Lens") } }) 1 5 6
18 1 croak "Lens method did not return a Data::Focus::Lens";
19 }
20 5 return $assoc_lens;
21 }
22 60 my $ref = ref($target);
23 60 ▶ if(!defined($target) || $ref eq "HASH" || $ref eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $target or $ref eq "HASH" or $ref eq "ARRAY") 56 4 60
Condition100%6/6
not defined $target or $ref eq "HASH" or $ref eq "ARRAY"
l!l&&r!l&&!r
34224
not defined $target or $ref eq "HASH"
l!l&&r!l&&!r
23226
MC/DC100%3/3
not defined $target or $ref eq "HASH" or $ref eq "ARRAY"
not defined $target $ref eq "HASH" $ref eq "ARRAY"
Truth table100%4/4
not(A) or B or C
A= not defined $targetB= $ref eq "HASH"C= $ref eq "ARRAY"
ABCresult
1XX1
01X1
0011
0000
24 56 require Data::Focus::Lens::HashArray::Index;
25 56 return Data::Focus::Lens::HashArray::Index->new(index => $$self);
26 }
27 4 return undef;
28 }
29  
30 67 ▶sub apply_lens {
Subroutine apply_lens: called CC=2 SCAR=6.9
Pod documented
31 67 my ($self, $applicative_class, $part_mapper, $target) = @_;
32 67 my $assoc_lens = $self->_associated_lens($target);
33 65 ▶ if(defined($assoc_lens)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $assoc_lens) { } 61 4 65
34 61 return $assoc_lens->apply_lens($applicative_class, $part_mapper, $target);
35 }else {
36 4 return $applicative_class->pure($target);
37 }
38 }
39  
40  
41 6 1;
42 __END__
« Focus/Lens/HashArray/Index.pm ↑ Summary Focus/LensTester.pm »