Pure/DataProxy.pm

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 6 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 69.0% 38 / 55 CC 8 SCAR 18.8
CC
8
Cov
70%
AUTOLOAD
11.7
new
2.1
BEGIN
1.0
CRAP 6.5
« Pure.pm ↑ Summary Pure/Filters.pm »
1 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Template::Pure::DataProxy;
5  
6 13 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10 4 ▶ my ($proto, $data, %extra) = @_;
Subroutine new: called CC=2 SCAR=7.6
Pod undocumented
11 4 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
12 4 bless +{
13 data => $data,
14 extra => \%extra,
15 }, $class;
16 }
17  
18 7 ▶sub can { 1 } # Evil, sorry
Subroutine can: called CC=1 SCAR=0.0
Pod undocumented
19  
20 sub AUTOLOAD {
21 11 ▶ return if our $AUTOLOAD =~ /DESTROY/;
Subroutine AUTOLOAD: called CC=7 SCAR=24.6
Branch: 1 branch
BranchTrueFalseTotal
if our $AUTOLOAD =~ /DESTROY/ 4 7 11
22 7 my $self = shift;
23 7 ( my $method = $AUTOLOAD ) =~ s{.*::}{};
24 7 ▶ if(Scalar::Util::blessed $self->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($self->{'data'})) { } 0 7 7
25 0 ▶ if($self->{data}->can($method)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'data'}->can($method)) { } 0 0 0
elsif (exists $self->{'extra'}{$method}) { } 0 0 0
26 0 return $self->{data}->$method;
27 } elsif(exists $self->{extra}{$method}) {
28 0 return $self->{extra}{$method};
29 } else {
30 0 die "No value at $method for $self";
31 }
32 } else {
33 ## I think we can assume its a hashref then.
34 7 ▶ if(exists $self->{data}{$method}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'data'}{$method}) { } 5 2 7
elsif (exists $self->{'extra'}{$method}) { } 2 0 2
35 5 return $self->{data}{$method};
36 } elsif(exists $self->{extra}{$method}) {
37 2 return $self->{extra}{$method};
38 } else {
39 0 die "No value at $method in: ".Dumper $self;
40 }
41 }
42 }
43  
44 13 1;
45  
« Pure.pm ↑ Summary Pure/Filters.pm »