Infrastructure/Config/Hash.pm

filter: Statementstmt 16.6% 6 / 36 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 16.6% 1 / 6 Podpod 0.0% 0 / 2 totaltotal 10.0% 7 / 70 CC 10 SCAR 28.4
CC
10
Cov
11%
_get_hash_node
30.0
_get_hash_value
20.0
get_node
6.0
CRAP 17.1
↑ Summary Infrastructure/Utils.pm »
1 package Test::BDD::Infrastructure::Config::Hash;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: configuration class for Test::BDD::Infrastructure
6 1 our $VERSION = '1.005'; # VERSION
7  
8 1 has 'config' => ( is => 'rw', isa => 'HashRef', required => 1 );
9  
10 0 ▶sub _get_hash_node {
Subroutine _get_hash_node: not called CC=5 SCAR=34.0
11 0 my $hash = shift;
12 0 my @path = @_;
13 0 my $cur = $hash;
14  
15 0 ▶ if( ! defined $hash ) { return; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $hash) 0 0 0
16  
17 0 ▶ while( my $element = shift @path ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $element = shift @path) 0 0 0
18 0 ▶ if( defined $cur->{$element}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cur->{$element} and ref $cur->{$element} eq 'HASH') { } 0 0 0
Condition0%0/3
defined $cur->{$element} and ref $cur->{$element} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cur->{$element} and ref $cur->{$element} eq "HASH"
defined $cur->{$element} ref $cur->{$element} eq "HASH"
Truth table0%0/3
A and B
A= defined $cur->{$element}B= ref $cur->{$element} eq "HASH"
ABresult
0X0
100
111
19 && ref $cur->{$element} eq 'HASH' ) {
20 0 $cur = $cur->{$element};
21 0 } else { return; }
22 }
23  
24 0 return $cur;
25 }
26  
27 0 ▶sub _get_hash_value {
Subroutine _get_hash_value: not called CC=4 SCAR=30.0
28 0 my $hash = shift;
29 0 my $key = pop;
30 0 my @path = @_;
31  
32 0 my $cur = _get_hash_node( $hash, @path );
33  
34 0 ▶ if( defined $cur
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cur and defined $cur->{$key} and not ref $cur->{$key}) 0 0 0
Condition0%0/6
defined $cur and defined $cur->{$key} and not ref $cur->{$key}
!ll&&!rl&&r
000
defined $cur and defined $cur->{$key}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $cur and defined $cur->{$key} and not ref $cur->{$key}
defined $cur defined $cur->{$key} not ref $cur->{$key}
Truth table0%0/4
A and B and not(C)
A= defined $curB= defined $cur->{$key}C= not ref $cur->{$key}
ABCresult
0XX0
10X0
1100
1111
35 && defined $cur->{$key}
36 && ! ref($cur->{$key}) ) {
37 0 return $cur->{$key};
38 }
39 0 return;
40 }
41  
42 0 ▶sub _parse_path {
Subroutine _parse_path: not called CC=1 SCAR=6.9
43 0 my ( $self, $path ) = @_;
44 0 $path =~ s/^\///;
45 0 return( split('/', $path) );
46 }
47  
48 0 ▶sub get_node {
Subroutine get_node: not called CC=2 SCAR=17.9
Pod undocumented
49 0 my ( $self, $path ) = @_;
50 0 my $node;
51 0 ▶ if( $node = _get_hash_node( $self->config, $self->_parse_path( $path ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node = _get_hash_node($self->config, $self->_parse_path($path))) 0 0 0
52 0 return $node;
53 }
54 0 return;
55 }
56  
57 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod undocumented
58 0 my ( $self, $path ) = @_;
59 0 my $value;
60  
61 0 ▶ if( $value = _get_hash_value( $self->config, $self->_parse_path( $path ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value = _get_hash_value($self->config, $self->_parse_path($path))) 0 0 0
62 0 return $value;
63 }
64 0 return;
65 }
66  
67 1 1;
68  
69 __END__
↑ Summary Infrastructure/Utils.pm »