blib/lib/W3C/SOAP/XSD/Document/ComplexType.pm

filter: Statementstmt 96.8% 61 / 63 Branchbran 87.5% 7 / 8 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 92.3% 12 / 13 Podpod n/a totaltotal 83.8% 83 / 99 CC 11 SCAR 10.8
CC
11
Cov
89%
_complex_content
6.0
_get_sequence_elements
5.0
_sequence
3.0
CRAP 2.9
« blib/lib/W3C/SOAP/Parser.pm ↑ Summary blib/lib/W3C/SOAP/WSDL/Document/InOutPuts.pm »
1 package W3C::SOAP::XSD::Document::ComplexType;
2  
3 # Created on: 2012-05-26 19:04:25
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 #use List::MoreUtils;
15 7 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 7 ▶use W3C::SOAP::Utils qw/split_ns/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 7 extends 'W3C::SOAP::XSD::Document::Type';
20  
21 7 our $VERSION = 0.13;
22  
23 7 has sequence => (
24 is => 'rw',
25 isa => 'ArrayRef[W3C::SOAP::XSD::Document::Element]',
26 builder => '_sequence',
27 lazy => 1,
28 );
29 7 has module => (
30 is => 'rw',
31 isa => 'Str',
32 builder => '_module',
33 lazy => 1,
34 );
35 7 has complex_content => (
36 is => 'rw',
37 isa => 'Str',
38 builder => '_complex_content',
39 lazy => 1,
40 );
41 7 has extension => (
42 is => 'rw',
43 isa => 'Maybe[Str]',
44 builder => '_extension',
45 lazy => 1,
46 );
47  
48 sub _sequence {
49 35 ▶ my ($self) = @_;
Subroutine _sequence: called CC=3 SCAR=11.0
50 35 my ($node) = $self->document->xpc->findnodes('xsd:complexContent/xsd:extension', $self->node);
51 35 ▶ if (!$node) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node) 33 2 35
52 33 ($node) = $self->document->xpc->findnodes('xsd:extension', $self->node);
53 }
54  
55 35 ▶ return $self->_get_sequence_elements($node || $self->node);
Condition66%2/3
$node || $self->node
l!l&&r!l&&!r
4310
MC/DC0%0/2
$node || $self->node
$node $self->node
Truth table66%2/3
A || B
A= $nodeB= $self->node
ABresult
1X1
011
000
56 }
57  
58 sub _module {
59 20 ▶ my ($self) = @_;
Subroutine _module: called CC=2 SCAR=8.1
60  
61 20 ▶ return $self->document->module . '::' . ( $self->name || $self->parent_node->name );
Condition33%1/3
$self->name || $self->parent_node->name
l!l&&r!l&&!r
2000
MC/DC0%0/2
$self->name || $self->parent_node->name
$self->name $self->parent_node->name
Truth table33%1/3
A || B
A= $self->nameB= $self->parent_node->name
ABresult
1X1
011
000
62 }
63  
64 sub _complex_content {
65 0 ▶ my ($self) = @_;
Subroutine _complex_content: not called CC=2 SCAR=17.9
66  
67 0 ▶ return $self->document->module . '::' . ( $self->name || $self->parent_node->name );
Condition0%0/3
$self->name || $self->parent_node->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->name || $self->parent_node->name
$self->name $self->parent_node->name
Truth table0%0/3
A || B
A= $self->nameB= $self->parent_node->name
ABresult
1X1
011
000
68 }
69  
70 sub _extension {
71 35 ▶ my ($self) = @_;
Subroutine _extension: called CC=3 SCAR=11.0
72  
73 # TODO $suffix feels like a hack, it fixes the tests but isn't really calculated to be the correct value
74 35 my $suffix = '';
75 35 my @nodes = $self->document->xpc->findnodes('xsd:complexContent/xsd:extension', $self->node);
76 35 ▶ if (!@nodes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@nodes) 33 2 35
77 33 @nodes = $self->document->xpc->findnodes('xsd:extension', $self->node);
78 33 $suffix = 'Type';
79 }
80  
81 35 for my $node (@nodes) {
82 4 my ($ns, $tag) = split_ns($node->getAttribute('base'));
83 4 my $ns_uri = $self->document->get_ns_uri($ns, $self->node);
84  
85 4 return $self->document->get_module_name( $ns_uri ) . "::$tag" . $suffix;
86 }
87  
88 31 return;
89 }
90  
91 sub _get_sequence_elements {
92 35 ▶ my ($self, $node) = @_;
Subroutine _get_sequence_elements: called CC=5 SCAR=16.1
93 35 my @nodes = $self->document->xpc->findnodes('xsd:sequence/*', $node);
94 35 my @sequence;
95 35 my $group = 1;
96  
97 35 for my $node (@nodes) {
98 437 ▶ if ( $node->nodeName =~ /(?:^|:)element$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->nodeName =~ /(?:^|:)element$/) { } 433 4 437
elsif ($node->nodeName =~ /(?:^|:)choice$/) { } 4 0 4
99 433 push @sequence, W3C::SOAP::XSD::Document::Element->new(
100 parent_node => $self,
101 node => $node,
102 );
103 }
104 elsif ( $node->nodeName =~ /(?:^|:)choice$/ ) {
105 4 my @choices = $self->document->xpc->findnodes('xsd:element', $node);
106 4 for my $choice (@choices) {
107 12 push @sequence, W3C::SOAP::XSD::Document::Element->new(
108 parent_node => $self,
109 node => $choice,
110 choice_group => $group,
111 );
112 }
113 4 $group++;
114 }
115 }
116  
117 35 return \@sequence;
118 }
119  
120 7 1;
121  
122 __END__
123  
124 =head1 NAME
125  
126 W3C::SOAP::XSD::Document::ComplexType - Represents complexType elements of XSD documents
127  
128 =head1 VERSION
129  
130 This documentation refers to W3C::SOAP::XSD::Document::ComplexType version 0.13.
131  
132  
133 =head1 SYNOPSIS
134  
135 use W3C::SOAP::XSD::Document::ComplexType;
136  
137 # Brief but working code example(s) here showing the most common usage(s)
138 # This section will be as far as many users bother reading, so make it as
139 # educational and exemplary as possible.
140  
141  
142 =head1 DESCRIPTION
143  
144 Represents a single XML Schema complex type definition.
145  
146 =head1 SUBROUTINES/METHODS
147  
148 =head1 DIAGNOSTICS
149  
150 =head1 CONFIGURATION AND ENVIRONMENT
151  
152 =head1 DEPENDENCIES
153  
154 =head1 INCOMPATIBILITIES
155  
156 =head1 BUGS AND LIMITATIONS
157  
158 There are no known bugs in this module.
159  
160 Please report problems to Ivan Wills (ivan.wills@gmail.com).
161  
162 Patches are welcome.
163  
164 =head1 AUTHOR
165  
166 Ivan Wills - (ivan.wills@gmail.com)
167  
168 =head1 LICENSE AND COPYRIGHT
169  
170 Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
171 All rights reserved.
172  
173 This module is free software; you can redistribute it and/or modify it under
174 the same terms as Perl itself. See L<perlartistic>. This program is
175 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
176 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
177 PARTICULAR PURPOSE.
178  
179 =cut
« blib/lib/W3C/SOAP/Parser.pm ↑ Summary blib/lib/W3C/SOAP/WSDL/Document/InOutPuts.pm »