blib/lib/XML/Pastor/Schema/Context.pm

filter: Statementstmt 98.3% 60 / 61 Branchbran 77.2% 17 / 22 Conditioncond 36.3% 4 / 11 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 100% 11 / 11 Podpod 25.0% 1 / 4 totaltotal 81.0% 94 / 116 CC 17 SCAR 17.6
CC
17
Cov
86%
namePath
10.6
findNode
6.0
new
4.3
CRAP 5.8
« blib/lib/XML/Pastor/Schema/Object.pm ↑ Summary blib/lib/XML/Pastor/Schema/ComplexType.pm »
1 10 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 #========================================================
7 package XML::Pastor::Schema::Context;
8
9 10 ▶use Class::Accessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use XML::Pastor::Stack;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use XML::Pastor::Schema::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 10 our @ISA = qw(Class::Accessor);
14
15 10 XML::Pastor::Schema::Context->mk_accessors(
16 qw( counter schema schema_url operation nodeStack targetNamespace));
17
18 #------------------------------------------------------------
19 24 ▶sub new {
Subroutine new: called CC=4 SCAR=14.6
Pod documented
20 24 my $proto = shift;
21 24 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0240
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
22 24 my $self = {@_};
23
24 24 ▶ unless ($self->{nodeStack}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"nodeStack"}) 24 0 24
25 24 $self->{nodeStack} = XML::Pastor::Stack->new();
26 }
27
28 24 ▶ unless (defined($self->{counter})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"counter"}) 24 0 24
29 24 $self->{counter} = 0;
30 }
31
32 24 return bless $self, $class;
33 }
34
35 #------------------------------------------------------------
36 402 ▶sub topNode {
Subroutine topNode: called CC=1 SCAR=0.0
Pod undocumented
37 402 my $self = shift;
38 402 return $self->nodeStack()->peek();
39 }
40
41 #------------------------------------------------------------
42 525 ▶sub findNode {
Subroutine findNode: called CC=6 SCAR=17.9
Pod undocumented
43 525 my $self = shift;
44 525 my $args = {@_};
45 525 my $class = $args->{class};
46
47 525 my $nodeStack = $self->nodeStack();
48 525 ▶ for(my $i=0; $i< $nodeStack->count(); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nodeStack->count) 605 107 712
49 605 my $node = $nodeStack->get($i);
50 # print "\n", ref($node);
51 605 ▶ if (ref($class) =~ /ARRAY/) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref($class) =~ /ARRAY/) { } 385 220 605
elsif (UNIVERSAL::isa($node, $class)) { } 126 94 220
52 385 foreach my $c (@$class) {
53 522 ▶ if(UNIVERSAL::isa ($node, $c)) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($node, $c)) 292 230 522
54 292 return $node;
55 }
56 }
57 }elsif(UNIVERSAL::isa ($node, $class)) {
58 126 return $node;
59 }
60 }
61 107 return undef;
62 }
63
64 #------------------------------------------------------------
65 33 ▶sub namePath {
Subroutine namePath: called CC=9 SCAR=23.6
Pod undocumented
66 33 my $self = shift;
67 33 my $args = {@_};
68 33 ▶ my $separator = $args->{separator} || '/';
Condition50%1/2
$args->{'separator'} || '/'
l!l
330
MC/DC0%0/1
$args->{'separator'} || '/'
$args->{'separator'}
Truth table50%1/2
A
A= $args->{'separator'}
Aresult
11
00
69 33 my @names =();
70
71 33 my $nodeStack = $self->nodeStack();
72 33 ▶ for(my $i=0; $i< $nodeStack->count(); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nodeStack->count) 120 33 153
73 120 my $node = $nodeStack->get($i);
74 120 my $name = undef;
75 120 ▶ if (UNIVERSAL::can ($node, "nameIsAutoGenerated") && $node->nameIsAutoGenerated() ) {
Branch: 3 branches
BranchTrueFalseTotal
if (UNIVERSAL::can($node, 'nameIsAutoGenerated') and $node->nameIsAutoGenerated) { } 11 109 120
elsif (UNIVERSAL::can($node, 'name')) { } 109 0 109
elsif (ref($node) =~ /HASH/ and $node->{'name'}) { } 0 0 0
Condition66%2/3
UNIVERSAL::can($node, "nameIsAutoGenerated") and $node->nameIsAutoGenerated
!ll&&!rl&&r
010911
MC/DC50%1/2
UNIVERSAL::can($node, "nameIsAutoGenerated") and $node->nameIsAutoGenerated
UNIVERSAL::can($node, "nameIsAutoGenerated") $node->nameIsAutoGenerated
Truth table66%2/3
A and B
A= UNIVERSAL::can($node, "nameIsAutoGenerated")B= $node->nameIsAutoGenerated
ABresult
0X0
100
111
76 # ignore auto-generated names
77 11 $name = undef;
78 }elsif (UNIVERSAL::can ($node, "name")) {
79 109 $name = $node->name();
80 ▶ }elsif ((ref($node) =~ /HASH/) && $node->{name}) {
Condition0%0/3
ref($node) =~ /HASH/ and $node->{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref($node) =~ /HASH/ and $node->{"name"}
ref($node) =~ /HASH/ $node->{"name"}
Truth table0%0/3
A and B
A= ref($node) =~ /HASH/B= $node->{"name"}
ABresult
0X0
100
111
81 0 $name = $node->{name};
82 }
83
84 120 ▶ if ($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) 48 72 120
85 48 unshift @names,$name;
86 }
87 }
88 33 return join $separator, @names;
89 }
90
91
92 10 1;
« blib/lib/XML/Pastor/Schema/Object.pm ↑ Summary blib/lib/XML/Pastor/Schema/ComplexType.pm »