lib/XML/Compile/RPC/Util.pm

filter: Statementstmt 100% 56 / 56 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 12 / 12 Podpod 100% 8 / 8 totaltotal 93.2% 83 / 89 CC 10 SCAR 8.1
CC
10
Cov
93%
fault_code
3.0
rpcarray_values
3.0
struct_to_hash
3.0
CRAP 2.2
« blib/lib/XML/Compile/RPC/Util.pm ↑ Summary lib/XML/Compile/RPC.pm »
1 # Copyrights 2009-2013 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package XML::Compile::RPC::Util;
9 5 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 $VERSION = '0.17';
11  
12 5 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 our @EXPORT = qw/
15 struct_to_hash
16 struct_to_rows
17 struct_from_rows
18 struct_from_hash
19  
20 rpcarray_values
21 rpcarray_from
22  
23 fault_code
24 fault_from
25 /;
26  
27  
28 sub struct_to_hash($)
29 4 ▶{ my $s = shift;
Subroutine struct_to_hash: called CC=3 SCAR=11.0
Pod documented
30 4 my %h;
31  
32 4 ▶ foreach my $member ( @{$s->{member} || []} )
Branch: 1 branch
BranchTrueFalseTotal
$s->{"member"} or [] 0 4 4
33 9 { my ($type, $value) = %{$member->{value}};
34 9 $h{$member->{name}} = $value;
35 }
36  
37 4 \%h;
38 }
39  
40  
41 sub struct_to_rows($)
42 1 ▶{ my $s = shift;
Subroutine struct_to_rows: called CC=3 SCAR=11.0
Pod documented
43 1 my @r;
44  
45 1 ▶ foreach my $member ( @{$s->{member} || []} )
Branch: 1 branch
BranchTrueFalseTotal
$s->{"member"} or [] 0 1 1
46 3 { my ($type, $value) = %{$member->{value}};
47 3 push @r, [ $member->{name}, $type, $value ];
48 }
49  
50 1 @r;
51 }
52  
53  
54 sub struct_from_rows(@)
55 2 ▶{ my @members = map { +{name => $_->[0], value => {$_->[1] => $_->[2]}}} @_;
Subroutine struct_from_rows: called CC=1 SCAR=0.0
Pod documented
56 2 +{ struct => {member => \@members} };
57 }
58  
59  
60 sub struct_from_hash($$)
61 1 ▶{ my ($type, $hash) = @_;
Subroutine struct_from_hash: called CC=2 SCAR=7.0
Pod documented
62 3 my @members = map { +{name => $_, value => {$type => $hash->{$_}}} }
63 1 ▶ sort keys %{$hash || {}};
Branch: 1 branch
BranchTrueFalseTotal
$hash or {} 0 1 1
64 1 +{ struct => {member => \@members} };
65 }
66  
67  
68 sub rpcarray_values($)
69 1 ▶{ my $rpca = shift;
Subroutine rpcarray_values: called CC=3 SCAR=11.0
Pod documented
70 1 my @v;
71 1 ▶ foreach ( @{$rpca->{data}{value} || []} )
Branch: 1 branch
BranchTrueFalseTotal
$rpca->{"data"}{"value"} or [] 0 1 1
72 3 { my ($type, $value) = %$_;
73 3 push @v, $value;
74 }
75 1 @v;
76 }
77  
78  
79 sub rpcarray_from($@)
80 1 ▶{ my $type = shift;
Subroutine rpcarray_from: called CC=1 SCAR=0.0
Pod documented
81 1 my @values = map { +{$type => $_} } @_;
82 1 +{array => {data => {value => \@values}}};
83 }
84  
85  
86 sub fault_code($)
87 3 ▶{ my $h = struct_to_hash shift->{value}{struct};
Subroutine fault_code: called CC=3 SCAR=11.1
Pod documented
88 3 ▶ my $fc = $h->{faultCode} || -1;
Condition50%1/2
$h->{'faultCode'} || -1
l!l
30
MC/DC0%0/1
$h->{'faultCode'} || -1
$h->{'faultCode'}
Truth table50%1/2
A
A= $h->{'faultCode'}
Aresult
11
00
89 3 ▶ wantarray ? ($fc, $h->{faultString}) : $fc;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 1 3
90 }
91  
92  
93 sub fault_from($$)
94 1 ▶{ my ($rc, $msg) = @_;
Subroutine fault_from: called CC=1 SCAR=0.0
Pod documented
95 1 my @rows = ([faultCode => int => $rc], [faultString => string => $msg]);
96 1 +{fault => {value => struct_from_rows(@rows)}};
97 }
98  
99 5 1;
« blib/lib/XML/Compile/RPC/Util.pm ↑ Summary lib/XML/Compile/RPC.pm »