Petitcom/Resource.pm

filter: Statementstmt 94.8% 37 / 39 Branchbran 60.0% 6 / 10 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 6 totaltotal 78.3% 58 / 74 CC 9 SCAR 9.3
CC
9
Cov
87%
init
4.1
new
3.1
get_resource
3.0
CRAP 2.5
« Petitcom/Resource/GRP.pm ↑ Summary Petitcom/PTC.pm »
1 package Data::Petitcom::Resource;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use parent qw{ Exporter };
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 our @EXPORT = qw{ get_resource };
8  
9 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use Module::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 ▶sub get_resource {
Subroutine get_resource: called CC=3 SCAR=11.0
Pod undocumented
13 13 my %opts = @_;
14 13 ▶ my $resource = delete $opts{resource} || 'PRG';
Condition100%2/2
delete $opts{'resource'} || 'PRG'
l!l
121
MC/DC100%1/1
delete $opts{'resource'} || 'PRG'
delete $opts{'resource'}
Truth table100%2/2
A
A= delete $opts{'resource'}
Aresult
11
00
15 13 my $pkg_resource = join '::', __PACKAGE__, uc($resource);
16 13 Module::Load::load $pkg_resource;
17 12 my $obj_resource = $pkg_resource->new( resource => $resource, %opts );
18 12 ▶ Carp::croak "initialize failed: $!"
Branch: 1 branch
BranchTrueFalseTotal
unless $obj_resource->isa(__PACKAGE__) 0 12 12
19 unless ( $obj_resource->isa(__PACKAGE__) );
20 12 return $obj_resource;
21 }
22  
23 8 my %defaults = ( data => undef );
24  
25 18 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod undocumented
26 18 ▶ my $class = ref $_[0] ? ref shift : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 18 18
27 18 my $self = bless {@_}, $class;
28 18 ▶ $self->init() if ( $self->can('init') );
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("init") 18 0 18
29 18 return $self;
30 }
31  
32 18 ▶sub init {
Subroutine init: called CC=4 SCAR=14.2
Pod undocumented
33 18 my $self = shift;
34 18 for ( keys %defaults ) {
35 18 ▶ my $value = $self->{$_} || $defaults{$_};
Condition66%2/3
$self->{$_} || $defaults{$_}
l!l&&r!l&&!r
1017
MC/DC50%1/2
$self->{$_} || $defaults{$_}
$self->{$_} $defaults{$_}
Truth table66%2/3
A || B
A= $self->{$_}B= $defaults{$_}
ABresult
1X1
011
000
36 18 ▶ ( $self->can($_) ) ? $self->$_($value) : ( $self->{$_} = $value );
Branch: 1 branch
BranchTrueFalseTotal
$self->can($_) ? : 18 0 18
37 }
38 18 return $self;
39 }
40  
41 22 ▶sub data {
Subroutine data: called CC=2 SCAR=6.9
Pod undocumented
42 22 my $self = shift;
43 22 ▶ $self->{data} = shift if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 16 6 22
44 22 return $self->{data};
45 }
46  
47 0 ▶sub save { die "override save" }
Subroutine save: not called CC=1 SCAR=6.9
Pod undocumented
48 0 ▶sub load { die "override load" }
Subroutine load: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 8 1;
« Petitcom/Resource/GRP.pm ↑ Summary Petitcom/PTC.pm »