blib/lib/XML/TinyXML/Selector/XPath/Axes.pm

filter: Statementstmt 95.0% 77 / 81 Branchbran 70.5% 24 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 10 totaltotal 81.8% 113 / 138 CC 22 SCAR 13.6
CC
22
Cov
88%
ancestor
6.0
ancestor_or_self
6.0
following_sibling
5.0
CRAP 3.9
« blib/lib/XML/TinyXML/Selector/XPath/Context.pm ↑ Summary blib/lib/XML/TinyXML/NodeAttribute.pm »
1 package XML::TinyXML::Selector::XPath::Axes;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use XML::TinyXML::NodeAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 our $VERSION = "0.34";
8  
9 52 ▶sub child {
Subroutine child: called CC=2 SCAR=7.0
Pod undocumented
10 52 my ($class, $context) = @_;
11 52 my @res = map { $_->children } grep { defined } @{$context->items};
12 52 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 52 0 52
13 }
14  
15 40 ▶sub descendant {
Subroutine descendant: called CC=3 SCAR=11.0
Pod undocumented
16 40 my ($class, $context) = @_;
17 40 my @res = map { $_->children } @{$context->items};
18 40 ▶ if (@res) {
Branch: 1 branch
BranchTrueFalseTotal
if (@res) 26 14 40
19 26 my $newctx = XML::TinyXML::Selector::XPath::Context->new($context->xml);
20 26 $newctx->{items} = \@res;
21 26 push (@res, descendant($class, $newctx));
22 }
23 40 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 40 0 40
24 }
25  
26 3 ▶sub parent {
Subroutine parent: called CC=2 SCAR=7.0
Pod undocumented
27 3 my ($class, $context) = @_;
28 3 my @res = map { $_->parent } grep { defined } @{$context->items};
29 3 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 0 3
30 }
31  
32 3 ▶sub ancestor {
Subroutine ancestor: called CC=6 SCAR=17.9
Pod undocumented
33 3 my ($class, $context) = @_;
34 3 my @res;
35 3 foreach my $node (@{$context->items}) {
36 3 my $parent = $node->parent;
37 3 ▶ push(@res, $parent)
Branch: 1 branch
BranchTrueFalseTotal
if $parent 2 1 3
38 if($parent);
39 }
40  
41 3 ▶ if (@res) {
Branch: 1 branch
BranchTrueFalseTotal
if (@res) 2 1 3
42 2 my $newctx = XML::TinyXML::Selector::XPath::Context->new($context->xml);
43 2 $newctx->{items} = \@res;
44 2 my @new = ancestor($class, $newctx);
45 2 ▶ push (@res, @new)
Branch: 1 branch
BranchTrueFalseTotal
if @new 1 1 2
46 if (@new);
47 }
48 3 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 0 3
49 }
50  
51 2 ▶sub following_sibling {
Subroutine following_sibling: called CC=5 SCAR=16.1
Pod undocumented
52 2 my ($class, $context) = @_;
53 2 my @res;
54 2 foreach my $node (@{$context->items}) {
55 2 ▶ while ($node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node) 5 2 7
56 5 my $next = $node->nextSibling;
57 5 ▶ push (@res, $next) if $next;
Branch: 1 branch
BranchTrueFalseTotal
if $next 3 2 5
58 5 $node = $next;
59 }
60 }
61 2 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 0 2
62 }
63  
64 1 ▶sub preceding_sibling {
Subroutine preceding_sibling: called CC=5 SCAR=16.1
Pod undocumented
65 1 my ($class, $context) = @_;
66 1 my @res;
67 1 foreach my $node (@{$context->items}) {
68 1 ▶ while ($node) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node) 4 1 5
69 4 my $prev = $node->prevSibling;
70 4 ▶ push (@res, $prev) if $prev;
Branch: 1 branch
BranchTrueFalseTotal
if $prev 3 1 4
71 4 $node = $prev;
72 }
73 }
74 1 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
75 }
76  
77 10 ▶sub attribute {
Subroutine attribute: called CC=2 SCAR=7.0
Pod undocumented
78 10 my ($class, $context) = @_;
79 10 my @res = map { $_->getAttributes } grep { defined } @{$context->items};
80 10 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 10 0 10
81 }
82  
83 2 ▶sub self {
Subroutine self: called CC=1 SCAR=0.0
Pod undocumented
84 2 my ($class, $context) = @_;
85 2 return @{$context->items};
86 }
87  
88 13 ▶sub descendant_or_self {
Subroutine descendant_or_self: called CC=3 SCAR=11.0
Pod undocumented
89 13 my ($class, $context) = @_;
90 13 my @res = descendant($class, $context);
91 13 foreach my $node (@{$context->items}) {
92 12 push (@res, $node);
93 }
94 13 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 13 0 13
95 }
96  
97 0 ▶sub ancestor_or_self {
Subroutine ancestor_or_self: not called CC=2 SCAR=17.9
Pod undocumented
98 0 my ($class, $context) = @_;
99 0 my @res = ancestor($context);
100 0 unshift(@res, $context->{node});
101 0 ▶ return wantarray?@res:\@res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
102 }
103  
104  
105 4 1;
« blib/lib/XML/TinyXML/Selector/XPath/Context.pm ↑ Summary blib/lib/XML/TinyXML/NodeAttribute.pm »