| 1 | package Shipment::Address; | ||||||||||||||||||||||||||||||||
| 2 | 3 | $Shipment::Address::VERSION = '3.11'; | |||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use MooX::Aliases; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 3 | has 'name' => ( | |||||||||||||||||||||||||||||||
| 14 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 15 | isa => Str, | ||||||||||||||||||||||||||||||||
| 16 | alias => 'contact', | ||||||||||||||||||||||||||||||||
| 17 | default => '', | ||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 3 | has 'company' => ( | |||||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 23 | isa => Str, | ||||||||||||||||||||||||||||||||
| 24 | default => 'n/a', | ||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 3 | has 'address_type' => ( | |||||||||||||||||||||||||||||||
| 29 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 30 | isa => Enum [qw/residential business/], | ||||||||||||||||||||||||||||||||
| 31 | default => 'business', | ||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 3 | has 'address1' => ( | |||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 37 | isa => Str, | ||||||||||||||||||||||||||||||||
| 38 | default => '', | ||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 3 | has 'address2' => ( | |||||||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 43 | isa => Str, | ||||||||||||||||||||||||||||||||
| 44 | default => '', | ||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 3 | has 'address3' => ( | |||||||||||||||||||||||||||||||
| 48 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 49 | isa => Str, | ||||||||||||||||||||||||||||||||
| 50 | default => '', | ||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 3 | has 'city' => ( | |||||||||||||||||||||||||||||||
| 55 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 56 | isa => Str, | ||||||||||||||||||||||||||||||||
| 57 | alias => 'town', | ||||||||||||||||||||||||||||||||
| 58 | default => '', | ||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 3 | has 'province' => ( | |||||||||||||||||||||||||||||||
| 63 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 64 | isa => Str, | ||||||||||||||||||||||||||||||||
| 65 | alias => 'state', | ||||||||||||||||||||||||||||||||
| 66 | default => '', | ||||||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 3 | has 'province_code' => ( | |||||||||||||||||||||||||||||||
| 71 | is => 'lazy', | ||||||||||||||||||||||||||||||||
| 72 | isa => Str, | ||||||||||||||||||||||||||||||||
| 73 | alias => 'state_code', | ||||||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | sub _build_province_code { | ||||||||||||||||||||||||||||||
|
Subroutine
_build_province_code: called CC=6 SCAR=21.2
| |||||||||||||||||||||||||||||||||
| 77 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | return '' unless ($self->province && $self->country); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->province and $self->country
MC/DC0%0/2
$self->province and $self->country
$self->province
$self->country
Truth table33%1/3
A and B
A= $self->provinceB= $self->country
| |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | use Locale::SubCountry; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 82 | 2 | my $country = Locale::SubCountry->new($self->country_code); | |||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | return ($country->code($self->province) eq 'unknown') | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$country and $country->code($self->province)
MC/DC0%0/2
$country and $country->code($self->province)
$country
$country->code($self->province)
Truth table33%1/3
A and B
A= $countryB= $country->code($self->province)
| |||||||||||||||||||||||||||||||||
| 85 | ? $self->province | ||||||||||||||||||||||||||||||||
| 86 | : $country->code($self->province) | ||||||||||||||||||||||||||||||||
| 87 | if $country && $country->code($self->province); | ||||||||||||||||||||||||||||||||
| 88 | 0 | return $self->province; | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 3 | has 'postal_code' => ( | |||||||||||||||||||||||||||||||
| 93 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 94 | isa => Str, | ||||||||||||||||||||||||||||||||
| 95 | alias => 'zip', | ||||||||||||||||||||||||||||||||
| 96 | default => '', | ||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 3 | has 'country' => ( | |||||||||||||||||||||||||||||||
| 101 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 102 | isa => Str, | ||||||||||||||||||||||||||||||||
| 103 | default => '', | ||||||||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 3 | has 'country_code' => (is => 'lazy',); | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | sub _build_country_code { | ||||||||||||||||||||||||||||||
|
Subroutine
_build_country_code: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||
| 110 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | 2 | ▶ | return '' unless $self->country; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 3 | ▶ | use Locale::SubCountry; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 115 | 2 | my $country = Locale::SubCountry->new($self->country); | |||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | return $country->country_code if $country && $country->country_code; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$country and $country->country_code
MC/DC0%0/2
$country and $country->country_code
$country
$country->country_code
Truth table33%1/3
A and B
A= $countryB= $country->country_code
| |||||||||||||||||||||||||||||||||
| 118 | 0 | return $self->country; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 3 | has 'address_components' => ( | |||||||||||||||||||||||||||||||
| 123 | is => 'lazy', | ||||||||||||||||||||||||||||||||
| 124 | isa => HashRef [Str], | ||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 2 | ▶ | sub _build_address_components { | ||||||||||||||||||||||||||||||
|
Subroutine
_build_address_components: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 128 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 2 | my %components; | |||||||||||||||||||||||||||||||
| 131 | 2 | $components{street} = uc($self->address1); | |||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | $components{direction} = | ||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | ($components{street} =~ s/\b(N|E|S|W|NE|NW|SE|SW|SO|NO|O)\b//) ? $1 : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | $components{number} = ($components{street} =~ s/^(\d+)//) ? $1 : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | 2 | $components{street} =~ s/(^\s+|\s+$)//g; | |||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | 2 | \%components; | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 3 | has 'phone' => ( | |||||||||||||||||||||||||||||||
| 143 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 144 | isa => Str, | ||||||||||||||||||||||||||||||||
| 145 | default => "", | ||||||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 3 | has 'phone_components' => ( | |||||||||||||||||||||||||||||||
| 150 | is => 'lazy', | ||||||||||||||||||||||||||||||||
| 151 | isa => HashRef [Str], | ||||||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | sub _build_phone_components { | ||||||||||||||||||||||||||||||
|
Subroutine
_build_phone_components: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||
| 155 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | 2 | my %components; | |||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 2 | my $phone = $self->phone; | |||||||||||||||||||||||||||||||
| 160 | 2 | $phone =~ s/[\sa-zA-Z]+.+$//; | |||||||||||||||||||||||||||||||
| 161 | 2 | $phone =~ s/\s//g; | |||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | 2 | my @parts = | |||||||||||||||||||||||||||||||
| 164 | ($phone | ||||||||||||||||||||||||||||||||
| 165 | =~ /^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/ | ||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | $components{country} = $parts[0] || "1"; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$parts[0] || '1'
MC/DC100%1/1
$parts[0] || '1'
$parts[0]
Truth table100%2/2
A
A= $parts[0]
| |||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | $components{area} = $parts[2] || ""; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$parts[2] || ''
MC/DC0%0/1
$parts[2] || ''
$parts[2]
Truth table50%1/2
A
A= $parts[2]
| |||||||||||||||||||||||||||||||||
| 170 | 2 | $components{area} =~ s/\D//g; | |||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | $components{phone} = $parts[4] || $phone || ""; | ||||||||||||||||||||||||||||||
|
Condition40%2/5
$parts[4] || $phone || ''
$parts[4] or $phone
MC/DC0%0/2
$parts[4] || $phone || ''
$parts[4]
$phone
Truth table33%1/3
A or B
A= $parts[4]B= $phone
| |||||||||||||||||||||||||||||||||
| 172 | 2 | $components{phone} =~ s/\D//g; | |||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 2 | \%components; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | 3 | has 'email' => ( | |||||||||||||||||||||||||||||||
| 179 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 180 | isa => Str, | ||||||||||||||||||||||||||||||||
| 181 | default => "", | ||||||||||||||||||||||||||||||||
| 182 | ); | ||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | 3 | 1; | |||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | __END__ | ||||||||||||||||||||||||||||||||