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

filter: Statementstmt 88.5% 54 / 61 Branchbran 67.6% 23 / 34 Conditioncond 42.1% 8 / 19 MC/DCmcdc 20.0% 2 / 10 Subroutinesub 100% 11 / 11 Podpod 83.3% 5 / 6 totaltotal 73.0% 103 / 141 CC 25 SCAR 19.5
CC
25
Cov
75%
class
15.1
refKey
8.6
key
6.7
CRAP 7.0
« blib/lib/XML/Pastor/Generator.pm ↑ Summary blib/lib/XML/Pastor/Schema/Context.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::Object;
8 10 ▶use base qw (Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 10 XML::Pastor::Schema::Object->mk_accessors(qw(class definition documentation isRedefinable metaClass name nameIsAutoGenerated ref refKey scope type targetNamespace));
11
12 #------------------------------------------------------------
13 306 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
14 306 my $proto = shift;
15 306 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
CORE::ref $proto || $proto
l!l&&r!l&&!r
03060
MC/DC0%0/2
CORE::ref $proto || $proto
CORE::ref $proto $proto
Truth table33%1/3
A || B
A= CORE::ref $protoB= $proto
ABresult
1X1
011
000
16 306 my $self = {@_};
17 306 return bless $self, $class;
18 }
19
20 #------------------------------------------------------------
21 151 ▶sub key {
Subroutine key: called CC=6 SCAR=19.0
Pod documented
22 151 my $self = shift;
23 151 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 151 151
24 return ($self->{key}=shift)
25 0 }
26 151 ▶ if ( exists $self->{key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"key"}) 0 151 151
27 0 return $self->{key};
28 }
29
30 # WAS
31 # return $self->name;
32
33 # Let's take a ride towards namespace support
34 151 my $name = $self->name;
35
36 151 ▶ return $name if ($name =~ /\|/);
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\|/ 0 151 151
37
38 151 ▶ my $ns = $self->targetNamespace || '';
Condition100%2/2
$self->targetNamespace || ''
l!l
9061
MC/DC100%1/1
$self->targetNamespace || ''
$self->targetNamespace
Truth table100%2/2
A
A= $self->targetNamespace
Aresult
11
00
39 151 ▶ return $self->name . ($ns ? '|' . $ns : "");
Branch: 1 branch
BranchTrueFalseTotal
$ns ? : 90 61 151
40 }
41
42 #------------------------------------------------------------
43 40 ▶sub refKey {
Subroutine refKey: called CC=7 SCAR=21.5
Pod undocumented
44 40 my $self = shift;
45 40 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 40 40
46 return ($self->{refKey}=shift)
47 0 }
48 40 ▶ if ( exists $self->{refKey}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"refKey"}) 0 40 40
49 0 return $self->{refKey};
50 }
51
52 # WAS
53 # return $self->ref();
54
55 # Let's take a ride towards namespace support
56 40 ▶ return undef unless $self->ref();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ref 0 40 40
57
58 40 my $ref = $self->ref;
59
60 40 ▶ return $ref if ($ref =~ /\|/);
Branch: 1 branch
BranchTrueFalseTotal
if $ref =~ /\|/ 20 20 40
61 20 ▶ my $ns = $self->targetNamespace || '';
Condition50%1/2
$self->targetNamespace || ''
l!l
020
MC/DC0%0/1
$self->targetNamespace || ''
$self->targetNamespace
Truth table50%1/2
A
A= $self->targetNamespace
Aresult
11
00
62 20 ▶ return $self->ref() . ($ns ? '|' . $ns : "");
Branch: 1 branch
BranchTrueFalseTotal
$ns ? : 0 20 20
63 }
64
65
66 #------------------------------------------------------------
67 # Set multiple fields (hash values) of this object all at once from a given
68 # hash.
69 554 ▶sub setFields {
Subroutine setFields: called CC=3 SCAR=11.0
Pod documented
70 554 my $self = shift;
71 554 my $h = $_[0]; # if the first argument is a hash-ref, use it.
72
73 # otherwise, use the argument list as a hash.
74 554 ▶ unless (ref($h) =~ /HASH/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (CORE::ref($h) =~ /HASH/) 18 536 554
75 18 $h = {@_};
76 }
77 554 ▶ while (my ($key, $value) = each %$h) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$h) 801 554 1355
78 801 $self->{$key} = $value;
79 }
80 554 return $self;
81 }
82
83 #----------------------------------------------------------
84 # override the accessor -- only for GET.
85 # Default to the value in "definition" if there is one.
86 872 ▶sub class {
Subroutine class: called CC=6 SCAR=27.1
Pod documented
87 872 my $self = shift;
88
89 # _class_accesor is an alias for class() made by Class::Accessor
90 # We are not interested by the SET case which should do the default.
91 872 ▶ return $self->_class_accessor(@_) if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 397 475 872
92
93 # if we have it defined here, just return it.
94 475 my $result = $self->_class_accessor();
95 475 ▶ return $result if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 475 0 475
96
97 # Otherwise, see if our "definition" has it. So we would effectively delegate.
98 0 my $definition = undef;
99 0 ▶ return $result unless (UNIVERSAL::can($self, "definition") && ($definition=$self->definition) && UNIVERSAL::can($definition, "class"));
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::can($self, "definition") and $definition = $self->definition and UNIVERSAL::can($definition, "class") 0 0 0
Condition0%0/6
UNIVERSAL::can($self, "definition") and $definition = $self->definition and UNIVERSAL::can($definition, "class")
!ll&&!rl&&r
000
UNIVERSAL::can($self, "definition") and $definition = $self->definition
!ll&&!rl&&r
000
MC/DC0%0/3
UNIVERSAL::can($self, "definition") and $definition = $self->definition and UNIVERSAL::can($definition, "class")
UNIVERSAL::can($self, "definition") $definition = $self->definition UNIVERSAL::can($definition, "class")
Truth table0%0/4
A and B and C
A= UNIVERSAL::can($self, "definition")B= $definition = $self->definitionC= UNIVERSAL::can($definition, "class")
ABCresult
0XX0
10X0
1100
1111
100 0 return $definition->class();
101 }
102
103 #----------------------------------------------------------
104 # override the accessor -- only for GET.
105 # Default to the value in "definition" if there is one.
106 542 ▶sub type {
Subroutine type: called CC=6 SCAR=18.2
Pod documented
107 542 my $self = shift;
108
109 # _type_accesor is an alias for type() made by Class::Accessor
110 # We are not interested by the SET case which should do the default.
111 542 ▶ return $self->_type_accessor(@_) if (@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 542 542
112
113 # if we have it defined here, just return it.
114 542 my $result = $self->_type_accessor();
115 542 ▶ return $result if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 458 84 542
116
117 # Otherwise, see if our "definition" has it. So we would effectively delegate.
118 84 my $definition = undef;
119 84 ▶ return $result unless (UNIVERSAL::can($self, "definition") && ($definition=$self->definition) && UNIVERSAL::can($definition, "type"));
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::can($self, "definition") and $definition = $self->definition and UNIVERSAL::can($definition, "type") 6 78 84
Condition66%4/6
UNIVERSAL::can($self, "definition") and $definition = $self->definition and UNIVERSAL::can($definition, "type")
!ll&&!rl&&r
6078
UNIVERSAL::can($self, "definition") and $definition = $self->definition
!ll&&!rl&&r
0678
MC/DC33%1/3
UNIVERSAL::can($self, "definition") and $definition = $self->definition and UNIVERSAL::can($definition, "type")
UNIVERSAL::can($self, "definition") $definition = $self->definition UNIVERSAL::can($definition, "type")
Truth table50%2/4
A and B and C
A= UNIVERSAL::can($self, "definition")B= $definition = $self->definitionC= UNIVERSAL::can($definition, "type")
ABCresult
0XX0
10X0
1100
1111
120 78 return $definition->type();
121 }
122
123 10 1;
124
125 __END__
« blib/lib/XML/Pastor/Generator.pm ↑ Summary blib/lib/XML/Pastor/Schema/Context.pm »