cXML/Address/Postal.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 55 / 55 CC 8 SCAR 15.5
CC
8
Cov
100%
to_node
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.7
« cXML/Amount.pm ↑ Summary cXML/Object.pm »
1 =encoding utf-8
2  
3 =head1 NAME
4  
5 Business::cXML::Address::Postal - cXML postal address
6  
7 =head1 SYNOPSIS
8  
9 use Business::cXML::Address::Postal;
10  
11 =head1 DESCRIPTION
12  
13 Object representation of a cXML C<PostalAddress>.
14  
15 =head1 METHODS
16  
17 See L<Business::cXML::Object/COMMON METHODS>.
18  
19 =head1 PROPERTY METHODS
20  
21 See L<Business::cXML::Object/PROPERTY METHODS> for how the following operate.
22  
23 =over
24  
25 =cut
26  
27 10 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 package Business::cXML::Address::Postal;
31 10 ▶use base qw(Business::cXML::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 10 ▶use constant NODENAME => 'PostalAddress';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 10 ▶use constant PROPERTIES => (
Subroutine BEGIN: called CC=1 SCAR=0.0
35 name => undef,
36 delivertos => [],
37 streets => [],
38 city => '',
39 muni => undef,
40 state => undef,
41 code => undef,
42 country_iso => '',
43 country => '',
44 10 );
45  
46 10 ▶use XML::LibXML::Ferry;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 3 ▶sub from_node {
Subroutine from_node: called CC=1 SCAR=0.0
Pod documented
49 3 my ($self, $el) = @_;
50  
51 3 $el->ferry($self, {
52 Municipality => 'muni',
53 PostalCode => 'code',
54 Country => {
55 isoCountryCode => 'country_iso',
56 __text => 'country',
57 },
58 }
59 );
60 }
61  
62 3 ▶sub to_node {
Subroutine to_node: called CC=8 SCAR=20.8
Pod documented
63 3 my ($self, $doc) = @_;
64 3 my $node = $doc->create($self->{_nodeName});
65 3 ▶ $node->{name} = $self->{name} if $self->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"name"} 2 1 3
66  
67 3 $node->add('DeliverTo', $_) foreach (@{ $self->{delivertos} });
68 3 $node->add('Street', $_) foreach (@{ $self->{streets} });
69 3 ▶ $node->add('Street', ' ') unless scalar(@{ $self->{streets} }); # At least one required
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"streets"};} 1 2 3
70 3 $node->add('City', $self->{city});
71 3 ▶ $node->add('Municipality', $self->{muni}) if $self->{muni};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"muni"} 2 1 3
72 3 ▶ $node->add('State', $self->{state}) if $self->{state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"state"} 2 1 3
73 3 ▶ $node->add('PostalCode', $self->{code}) if $self->{code};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"code"} 2 1 3
74 3 $node->add('Country', $self->{country}, isoCountryCode => $self->{country_iso});
75 3 return $node;
76 }
77  
78 =item C<B<name>>
79  
80 Optional, name of this address (i.e. C<billing department>)
81  
82 =item C<B<delivertos>[]>
83  
84 Optional
85  
86 =item C<B<streets>[]>
87  
88 Mandatory (at least one)
89  
90 =item C<B<city>>
91  
92 Mandatory
93  
94 =item C<B<muni>>
95  
96 Optional
97  
98 =item C<B<state>>
99  
100 Optional
101  
102 =item C<B<code>>
103  
104 Optional postal code
105  
106 =item C<B<country_iso>>
107  
108 Mandatory 2-letter ISO country code
109  
110 =item C<B<country>>
111  
112 Mandatory
113  
114 =back
115  
116 =head1 AUTHOR
117  
118 Stéphane Lavergne L<https://github.com/vphantom>
119  
120 =head1 ACKNOWLEDGEMENTS
121  
122 Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project.
123  
124 =head1 COPYRIGHT & LICENSE
125  
126 Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom>
127  
128 Permission is hereby granted, free of charge, to any person obtaining a copy
129 of this software and associated documentation files (the "Software"), to deal
130 in the Software without restriction, including without limitation the rights
131 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
132 copies of the Software, and to permit persons to whom the Software is
133 furnished to do so, subject to the following conditions:
134  
135 The above copyright notice and this permission notice shall be included in all
136 copies or substantial portions of the Software.
137  
138 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
140 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
141 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
142 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
143 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
144 SOFTWARE.
145  
146 =cut
147  
148 10 1;
« cXML/Amount.pm ↑ Summary cXML/Object.pm »