YADV/Structure/Base.pm

filter: Statementstmt 85.0% 34 / 40 Branchbran 80.0% 8 / 10 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 85.7% 12 / 14 Podpod 0.0% 0 / 9 totaltotal 75.0% 57 / 76 CC 7 SCAR 8.5
CC
7
Cov
85%
die
6.0
get_child
4.0
new
2.0
CRAP 2.4
« YADV/Checker.pm ↑ Summary YADV/Base.pm »
1 package Data::YADV::Structure::Base;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Data::YADV::Structure;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
9 40 my ($class, $structure, $path, $parent) = @_;
10  
11 40 ▶ bless {
Condition100%2/2
$path || []
l!l
3010
MC/DC100%1/1
$path || []
$path
Truth table100%2/2
A
A= $path
Aresult
11
00
12 structure => $structure,
13 path => $path || [],
14 parent => $parent
15 }, $class;
16 }
17  
18 42 ▶sub get_structure { $_[0]->{structure} }
Subroutine get_structure: called CC=1 SCAR=0.0
Pod undocumented
19 11 ▶sub get_parent { $_[0]->{parent} }
Subroutine get_parent: called CC=1 SCAR=0.0
Pod undocumented
20 0 ▶sub get_path { $_[0]->{path} }
Subroutine get_path: not called CC=1 SCAR=6.9
Pod undocumented
21 3 ▶sub get_type { lc((split /::/, (ref $_[0]))[-1]) }
Subroutine get_type: called CC=1 SCAR=0.0
Pod undocumented
22  
23 51 ▶sub get_child {
Subroutine get_child: called CC=4 SCAR=13.9
Pod undocumented
24 51 my ($self, @path) = @_;
25  
26 51 ▶ return $self unless @path;
Branch: 1 branch
BranchTrueFalseTotal
unless @path 15 36 51
27  
28 36 my $entry = shift @path;
29  
30 36 my $node;
31 36 ▶ if ($entry eq '..') {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry eq '..') { } 4 32 36
32 4 $node = $self->get_parent;
33 } else {
34 32 $node = $self->_get_child_node($entry);
35 }
36
37 36 ▶ $node && $node->get_child(@path);
Branch: 1 branch
BranchTrueFalseTotal
$node and $node->get_child(@path) 34 2 36
38 };
39  
40 5 ▶sub get_root {
Subroutine get_root: called CC=2 SCAR=6.9
Pod undocumented
41 5 my $self = shift;
42  
43 5 my $parent = $self->get_parent;
44 5 ▶ return $self unless $parent;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 1 4 5
45 4 $parent->get_root;
46 }
47  
48 1 ▶sub get_path_string {
Subroutine get_path_string: called CC=1 SCAR=0.0
Pod undocumented
49 1 my ($self, @path) = @_;
50 1 _stringify_path(@{$self->{path}}, @path);
51 }
52  
53 30 ▶sub _build_node {
Subroutine _build_node: called CC=1 SCAR=0.0
54 30 my ($self, $path, $value) = @_;
55  
56 30 Data::YADV::Structure->new($value, [@{$self->{path}}, $path], $self);
57 }
58  
59 1 ▶sub _stringify_path {
Subroutine _stringify_path: called CC=1 SCAR=0.0
60 1 join '->', @_;
61 }
62  
63 0 ▶sub die {
Subroutine die: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my ($self, $message, $path) = @_;
65  
66 0 my @path = @{$self->{path}};
67 0 ▶ push @path, $path if defined $path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $path 0 0 0
68  
69 0 die _stringify_path('$structure', @path) . ': ' .$message;
70 }
71  
72 1 1;
« YADV/Checker.pm ↑ Summary YADV/Base.pm »