| 1 | # Copyrights 2003-2022 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 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.03. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution User-Identity. Meta-POD processed with | ||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | package User::Identity::Location; | ||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '1.01'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use base 'User::Identity::Item'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use User::Identity; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Scalar::Util 'weaken'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub type { "location" } | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub init($) | ||||||||||||||||||||||||||||
| 26 | 4 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | $args->{postal_code} ||= delete $args->{pc}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args->{"postal_code"} ||= delete $args->{"pc"}
MC/DC50%1/2
$args->{"postal_code"} ||= delete $args->{"pc"}
$args->{"postal_code"}
delete $args->{"pc"}
Truth table66%2/3
A ||= B
A= $args->{"postal_code"}B= delete $args->{"pc"}
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | exists $args->{$_} && ($self->{'UIL_'.$_} = delete $args->{$_}) | ||||||||||||||||||||||||||||
| 33 | 4 | ▶ | foreach qw/city country country_code fax organization | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | pobox pobox_pc postal_code state street phone/; | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | $self; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | sub street() { shift->{UIL_street} } | ||||||||||||||||||||||||||
|
Subroutine
street: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | sub postalCode() { shift->{UIL_postal_code} } | ||||||||||||||||||||||||||
|
Subroutine
postalCode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | ▶ | sub pobox() { shift->{UIL_pobox} } | ||||||||||||||||||||||||||
|
Subroutine
pobox: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 2 | ▶ | sub poboxPostalCode() { shift->{UIL_pobox_pc} } | ||||||||||||||||||||||||||
|
Subroutine
poboxPostalCode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | #----------------------------------------- | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 2 | ▶ | sub city() { shift->{UIL_city} } | ||||||||||||||||||||||||||
|
Subroutine
city: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub state() { shift->{UIL_state} } | ||||||||||||||||||||||||||
|
Subroutine
state: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub country() | ||||||||||||||||||||||||||||
| 61 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
country: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | return $self->{UIL_country} | ||||||||||||||||||||||||||||
| 64 | 3 | ▶ | if defined $self->{UIL_country}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | ▶ | my $cc = $self->countryCode or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | eval 'require Geography::Countries'; | |||||||||||||||||||||||||||
| 69 | 1 | ▶ | return if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | scalar Geography::Countries::country($cc); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 5 | ▶ | sub countryCode() { shift->{UIL_country_code} } | ||||||||||||||||||||||||||
|
Subroutine
countryCode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub organization() { shift->{UIL_organization} } | ||||||||||||||||||||||||||
|
Subroutine
organization: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | #----------------------------------------- | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub phone() | ||||||||||||||||||||||||||||
| 84 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
phone: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 3 | ▶ | my $phone = $self->{UIL_phone} or return (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 3 | ▶ | my @phone = ref $phone ? @$phone : $phone; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 3 | ▶ | wantarray ? @phone : $phone[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | sub fax() | ||||||||||||||||||||||||||||
| 93 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
fax: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 3 | ▶ | my $fax = $self->{UIL_fax} or return (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 3 | ▶ | my @fax = ref $fax ? @$fax : $fax; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 3 | ▶ | wantarray ? @fax : $fax[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | #----------------------------------------- | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | sub fullAddress() | ||||||||||||||||||||||||||||
| 104 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
fullAddress: called CC=12 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||
| 105 | 2 | ▶ | my $cc = $self->countryCode || 'en'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->countryCode || 'en'
MC/DC0%0/1
$self->countryCode || 'en'
$self->countryCode
Truth table50%1/2
A
A= $self->countryCode
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 2 | my ($address, $pc); | |||||||||||||||||||||||||||
| 108 | 2 | ▶ | if($address = $self->pobox) { $pc = $self->poboxPostalCode } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 1 | else { $address = $self->street; $pc = $self->postalCode } | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 2 | my ($org, $city, $state) = @$self{ qw/UIL_organization UIL_city UIL_state/ }; | |||||||||||||||||||||||||||
| 112 | 2 | ▶ | return unless defined $city && defined $address; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $city and defined $address
MC/DC0%0/2
defined $city and defined $address
defined $city
defined $address
Truth table33%1/3
A and B
A= defined $cityB= defined $address
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | my $country = $self->country; | |||||||||||||||||||||||||||
| 115 | 2 | ▶ | $country | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 116 | = defined $country ? "\n$country" | ||||||||||||||||||||||||||||
| 117 | : defined $cc ? "\n".uc($cc) | ||||||||||||||||||||||||||||
| 118 | : ''; | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 2 | ▶ | if(defined $org) {$org .= "\n"} else {$org = ''}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 2 | ▶ | if($cc eq 'nl') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 2 | ▶ | { $pc = "$1 ".uc($2)." " if defined $pc && $pc =~ m/(\d{4})\s*([a-zA-Z]{2})/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $pc and $pc =~ /(\d{4})\s*([a-zA-Z]{2})/
MC/DC0%0/2
defined $pc and $pc =~ /(\d{4})\s*([a-zA-Z]{2})/
defined $pc
$pc =~ /(\d{4})\s*([a-zA-Z]{2})/
Truth table33%1/3
A and B
A= defined $pcB= $pc =~ /(\d{4})\s*([a-zA-Z]{2})/
| |||||||||||||||||||||||||||||
| 124 | 2 | return "$org$address\n$pc$city$country\n"; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | else | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | { $state ||= ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$state ||= ""
MC/DC0%0/1
$state ||= ""
$state
Truth table0%0/2
A
A= $state
| |||||||||||||||||||||||||||||
| 128 | 0 | return "$org$address\n$city$state$country\n$pc"; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 2 | 1; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||