| 1 | # This code is part of Perl distribution User-Identity version 4.00. | ||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.05. | ||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2003-2025 by Mark Overmeer. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | package User::Identity::Location;{ | ||||||||||||||||||||||||||||
| 13 | 2 | our $VERSION = '4.00'; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use parent 'User::Identity::Item'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Log::Report 'user-identity'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use User::Identity (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #-------------------- | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub type { 'location' } | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub init($) | ||||||||||||||||||||||||||||
| 32 | 4 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 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"}
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | exists $args->{$_} && ($self->{'UIL_'.$_} = delete $args->{$_}) | ||||||||||||||||||||||||||||
| 39 | 4 | ▶ | for qw/city country country_code fax organization pobox pobox_pc postal_code state street phone/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | $self; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | #-------------------- | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | ▶ | sub street() { $_[0]->{UIL_street} } | ||||||||||||||||||||||||||
|
Subroutine
street: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 2 | ▶ | sub postalCode() { $_[0]->{UIL_postal_code} } | ||||||||||||||||||||||||||
|
Subroutine
postalCode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3 | ▶ | sub pobox() { $_[0]->{UIL_pobox} } | ||||||||||||||||||||||||||
|
Subroutine
pobox: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | sub poboxPostalCode() { $_[0]->{UIL_pobox_pc} } | ||||||||||||||||||||||||||
|
Subroutine
poboxPostalCode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | sub city() { $_[0]->{UIL_city} } | ||||||||||||||||||||||||||
|
Subroutine
city: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub state() { $_[0]->{UIL_state} } | ||||||||||||||||||||||||||
|
Subroutine
state: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub country() | ||||||||||||||||||||||||||||
| 65 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
country: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 3 | ▶ | return $self->{UIL_country} if defined $self->{UIL_country}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | my $cc = $self->countryCode or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | eval 'require Geography::Countries'; | |||||||||||||||||||||||||||
| 71 | 1 | ▶ | return if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | scalar Geography::Countries::country($cc); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 5 | ▶ | sub countryCode() { $_[0]->{UIL_country_code} } | ||||||||||||||||||||||||||
|
Subroutine
countryCode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub organization() { $_[0]->{UIL_organization} } | ||||||||||||||||||||||||||
|
Subroutine
organization: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub phone() | ||||||||||||||||||||||||||||
| 84 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
phone: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 3 | ▶ | my $phone = $self->{UIL_phone} or return (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 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 | sub fullAddress() | ||||||||||||||||||||||||||||
| 102 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
fullAddress: called CC=13 SCAR=29.1
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 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
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | my ($address, $pc); | |||||||||||||||||||||||||||
| 106 | 2 | ▶ | if($address = $self->pobox) { $pc = $self->poboxPostalCode } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 1 | else { $address = $self->street; $pc = $self->postalCode } | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 2 | my ($org, $city, $state) = @$self{ qw/UIL_organization UIL_city UIL_state/ }; | |||||||||||||||||||||||||||
| 110 | 2 | ▶ | defined $city && defined $address or return; | ||||||||||||||||||||||||||
|
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
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 2 | my $country = $self->country; | |||||||||||||||||||||||||||
| 113 | 2 | ▶ | $country = defined $country ? "\n$country" : defined $cc ? "\n".uc($cc) : ''; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 2 | ▶ | $org .= defined $org && length $org ? "\n" : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $org and length $org
MC/DC50%1/2
defined $org and length $org
defined $org
length $org
Truth table66%2/3
A and B
A= defined $orgB= length $org
| |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 2 | ▶ | if($cc eq 'nl') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 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})/
| |||||||||||||||||||||||||||||
| 119 | 2 | return "$org$address\n$pc$city$country\n"; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | else | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | { $state ||= ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$state ||= ""
MC/DC0%0/1
$state ||= ""
$state
Truth table0%0/2
A
A= $state
| |||||||||||||||||||||||||||||
| 123 | 0 | return "$org$address\n$city$state$country\n$pc"; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 2 | 1; | |||||||||||||||||||||||||||