WSDL/Type.pm

filter: Statementstmt 54.9% 39 / 71 Branchbran 36.3% 8 / 22 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 56.8% 62 / 109 CC 16 SCAR 27.2
CC
16
Cov
53%
writeComplexType
42.0
_initPod
9.8
new
5.0
CRAP 15.2
« WSDL/Writer.pm ↑ Summary WSDL/AUTOLOAD.pm »
1 package Pod::WSDL::Type;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use Pod::WSDL::Attr;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Pod::WSDL::Utils qw(:writexml :namespaces :types);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Pod::WSDL::AUTOLOAD;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 our $VERSION = "0.05";
10 8 our @ISA = qw/Pod::WSDL::AUTOLOAD/;
11  
12 8 our %FORBIDDEN_METHODS = (
13 name => {get => 1, set => 0},
14 wsdlName => {get => 1, set => 0},
15 array => {get => 1, set => 1},
16 descr => {get => 1, set => 0},
17 attrs => {get => 1, set => 0},
18 writer => {get => 0, set => 0},
19 );
20  
21 6 ▶sub new {
Subroutine new: called CC=5 SCAR=16.1
Pod documented
22 6 my ($pkg, %data) = @_;
23
24 6 ▶ die "A type needs a name, died" unless $data{name};
Branch: 1 branch
BranchTrueFalseTotal
unless $data{"name"} 2 4 6
25  
26 4 my $wsdlName = $data{name};
27 4 $wsdlName =~ s/(?:^|::)(.)/uc $1/eg;
28
29 my $me = bless {
30 _name => $data{name},
31 _wsdlName => ucfirst $wsdlName,
32 _array => $data{array} || 0,
33 _attrs => [],
34 _descr => $data{descr} || '',
35 _writer => $data{writer},
36 4 ▶ _reftype => 'HASH',
Condition100%4/4
$data{'array'} || 0
l!l
31
$data{'descr'} || ''
l!l
31
MC/DC100%1/1
$data{'array'} || 0
$data{'array'}
MC/DC100%1/1
$data{'descr'} || ''
$data{'descr'}
Truth table100%2/2
A
A= $data{'array'}
Aresult
11
00
Truth table100%2/2
A
A= $data{'descr'}
Aresult
11
00
37 }, $pkg;
38  
39 4 ▶ $me->_initPod($data{pod}) if $data{pod};
Branch: 1 branch
BranchTrueFalseTotal
if $data{"pod"} 1 3 4
40  
41 4 return $me;
42 }
43  
44 1 ▶sub _initPod {
Subroutine _initPod: called CC=7 SCAR=22.8
45 1 my $me = shift;
46 1 my $pod = shift;
47
48 1 my @data = split "\n", $pod;
49
50 # Preprocess wsdl pod: trim all lines and concatenate lines not
51 # beginning with wsdl type tokens to previous line.
52 # Ignore first element, if it does not begin with wsdl type token.
53 1 ▶ for (my $i = $#data; $i >= 0; $i--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 6 1 7
54
55 6 ▶ if ($data[$i] !~ /^\s*(?:_ATTR|_REFTYPE)/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data[$i] =~ /^\s*(?:_ATTR|_REFTYPE)/i) 0 6 6
56 0 ▶ if ($i > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) 0 0 0
57 0 $data[$i - 1] .= " $data[$i]";
58 0 $data[$i] = '';
59 }
60 }
61 }
62  
63 1 for (@data) {
64 6 s/\s+/ /g;
65 6 s/^ //;
66 6 s/ $//;
67  
68 6 ▶ if (/^\s*_ATTR\s+/i) {
Branch: 2 branches
BranchTrueFalseTotal
if (/^\s*_ATTR\s+/i) { } 6 0 6
elsif (/^\s*_REFTYPE\s+(HASH|ARRAY)/i) { } 0 0 0
69 6 push @{$me->{_attrs}}, new Pod::WSDL::Attr($_);
70 } elsif (/^\s*_REFTYPE\s+(HASH|ARRAY)/i) {
71 0 $me->reftype(uc $1);
72 }
73 }
74
75 }
76  
77 0 ▶sub writeComplexType {
Subroutine writeComplexType: not called CC=6 SCAR=37.4
Pod documented
78 0 my $me = shift;
79 0 my $ownTypes = shift;
80  
81 0 $me->writer->wrElem($START_PREFIX_NAME, "complexType", name => $me->wsdlName);
82 0 $me->writer->wrDoc($me->descr, useAnnotation => 1);
83
84 0 ▶ if ($me->reftype eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($me->reftype eq 'HASH') { } 0 0 0
elsif ($me->reftype eq 'ARRAY') { } 0 0 0
85
86 0 $me->writer->wrElem($START_PREFIX_NAME, "sequence");
87
88 0 for my $attr (@{$me->attrs}) {
89 my %tmpArgs = (name => $attr->name,
90 0 type => Pod::WSDL::Utils::getTypeDescr($attr->type, $attr->array, $ownTypes->{$attr->type}));
91
92 0 ▶ $tmpArgs{nillable} = $attr->nillable if $attr->nillable;
Branch: 1 branch
BranchTrueFalseTotal
if $attr->nillable 0 0 0
93
94 0 $me->writer->wrElem($START_PREFIX_NAME, "element", %tmpArgs);
95 0 $me->writer->wrDoc($attr->descr, useAnnotation => 1);
96 0 $me->writer->wrElem($END_PREFIX_NAME, "element");
97 }
98
99 0 $me->writer->wrElem($END_PREFIX_NAME, "sequence");
100 } elsif ($me->reftype eq 'ARRAY') {
101 0 $me->writer->wrElem($START_PREFIX_NAME, "complexContent");
102 0 $me->writer->wrElem($START_PREFIX_NAME, "restriction", base => "soapenc:Array");
103 0 $me->writer->wrElem($EMPTY_PREFIX_NAME, "attribute", ref => $TARGET_NS_DECL . ':' . $me->wsdlName, "wsdl:arrayType" => 'xsd:anyType[]');
104 0 $me->writer->wrElem($END_PREFIX_NAME, "restriction");
105 0 $me->writer->wrElem($END_PREFIX_NAME, "complexContent");
106 }
107
108 0 $me->writer->wrElem($END_PREFIX_NAME, "complexType");
109  
110 0 ▶ if ($me->array) {
Branch: 1 branch
BranchTrueFalseTotal
if ($me->array) 0 0 0
111 0 $me->writer->wrElem($START_PREFIX_NAME, "complexType", name => $ARRAY_PREFIX_NAME . ucfirst $me->wsdlName);
112 0 $me->writer->wrElem($START_PREFIX_NAME, "complexContent");
113 0 $me->writer->wrElem($START_PREFIX_NAME, "restriction", base => "soapenc:Array");
114 0 $me->writer->wrElem($EMPTY_PREFIX_NAME, "attribute", ref => "soapenc:arrayType", "wsdl:arrayType" => $TARGET_NS_DECL . ':' . $me->wsdlName . '[]');
115 0 $me->writer->wrElem($END_PREFIX_NAME, "restriction");
116 0 $me->writer->wrElem($END_PREFIX_NAME, "complexContent");
117 0 $me->writer->wrElem($END_PREFIX_NAME, "complexType");
118 }
119 }
120  
121 8 1;
122 __END__
« WSDL/Writer.pm ↑ Summary WSDL/AUTOLOAD.pm »