DHL/Address.pm

filter: Statementstmt 100% 29 / 29 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 97.6% 41 / 42 CC 4 SCAR 6.4
CC
4
Cov
97%
as_hash
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.9
« DHL/Exception.pm ↑ Summary DHL/Types.pm »
1 package Net::Async::Webservice::DHL::Address;
2 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Types::Standard qw(Str Int Bool StrictNum);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Net::Async::Webservice::DHL::Types ':types';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 our $VERSION = '1.2.2'; # VERSION
7  
8 # ABSTRACT: an address for DHL
9  
10  
11 4 for my $l (1..3) {
12 12 has "line$l" => (
13 is => 'ro',
14 isa => Str,
15 required => 0,
16 );
17 }
18  
19  
20 4 has city => (
21 is => 'ro',
22 isa => Str,
23 required => 0,
24 );
25  
26  
27 4 has division => (
28 is => 'ro',
29 isa => Str,
30 required => 0,
31 );
32  
33  
34 4 has postal_code => (
35 is => 'ro',
36 isa => Str,
37 required => 0,
38 );
39  
40  
41 4 has country_code => (
42 is => 'ro',
43 isa => CountryCode,
44 required => 1,
45 );
46  
47  
48 4 has country_name => (
49 is => 'ro',
50 isa => Str,
51 required => 0,
52 );
53  
54  
55 8 ▶sub as_hash {
Subroutine as_hash: called CC=3 SCAR=11.0
Pod documented
56 8 my ($self,$shape) = @_;
57 26 ▶ my $if = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
58 26 my ($method,$key) = @_;
59 26 ▶ if ($self->$method) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->$method) 16 10 26
60 16 return ( $key => $self->$method );
61 }
62 10 return;
63 8 };
64  
65 8 ▶ if ($shape eq 'capability') {
Branch: 2 branches
BranchTrueFalseTotal
if ($shape eq 'capability') { } 6 2 8
elsif ($shape eq 'route') { } 2 0 2
66 return {
67 6 $if->(postal_code => 'Postalcode'),
68 $if->(city => 'City'),
69 CountryCode => $self->country_code,
70 };
71 }
72 elsif ($shape eq 'route') {
73 return {
74 2 $if->(line1 => 'Address1'),
75 $if->(line2 => 'Address2'),
76 $if->(line3 => 'Address3'),
77 $if->(postal_code => 'PostalCode'),
78 $if->(city => 'City'),
79 $if->(division => 'Division'),
80 CountryCode => $self->country_code,
81 CountryName => '', # the value is required, but an empty
82 # string will do
83 $if->(country_name => 'CountryName'),
84 };
85 };
86 }
87  
88 4 1;
89  
90 __END__
« DHL/Exception.pm ↑ Summary DHL/Types.pm »