User/Identity/Location.pm

filter: Statementstmt 92.5% 62 / 67 Branchbran 76.4% 26 / 34 Conditioncond 38.4% 5 / 13 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 90.0% 18 / 20 Podpod 92.8% 13 / 14 totaltotal 80.1% 125 / 156 SCAR 33.2
CC
24
Cov
82%
fullAddress
16.0
country
4.2
init
4.0
CRAP 27.6
« User/Identity/Collection.pm ↑ Summary User/Identity/Archive.pm »
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"}
l!l&&r!l&&!r
202
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"}
ABresult
1X1
011
000
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
BranchTrueFalseTotal
exists $args->{$_} and $$self{'UIL_' . $_} = delete $args->{$_} 24 20 44
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
BranchTrueFalseTotal
if defined $self->{"UIL_country"} 2 1 3
65  
66 1 ▶ my $cc = $self->countryCode or return;
Branch: 1 branch
BranchTrueFalseTotal
my $cc = $self->countryCode or return 0 1 1
67  
68 1 eval 'require Geography::Countries';
69 1 ▶ return if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 0 1
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
BranchTrueFalseTotal
my $phone = $self->{"UIL_phone"} or return () 0 3 3
87 3 ▶ my @phone = ref $phone ? @$phone : $phone;
Branch: 1 branch
BranchTrueFalseTotal
ref $phone ? : 2 1 3
88 3 ▶ wantarray ? @phone : $phone[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 2 3
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
BranchTrueFalseTotal
my $fax = $self->{"UIL_fax"} or return () 0 3 3
96 3 ▶ my @fax = ref $fax ? @$fax : $fax;
Branch: 1 branch
BranchTrueFalseTotal
ref $fax ? : 2 1 3
97 3 ▶ wantarray ? @fax : $fax[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 2 3
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'
l!l
20
MC/DC0%0/1
$self->countryCode || 'en'
$self->countryCode
Truth table50%1/2
A
A= $self->countryCode
Aresult
11
00
106  
107 2 my ($address, $pc);
108 2 ▶ if($address = $self->pobox) { $pc = $self->poboxPostalCode }
Branch: 1 branch
BranchTrueFalseTotal
if ($address = $self->pobox) { } 1 1 2
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
BranchTrueFalseTotal
unless defined $city and defined $address 0 2 2
Condition33%1/3
defined $city and defined $address
!ll&&!rl&&r
002
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
ABresult
0X0
100
111
113  
114 2 my $country = $self->country;
115 2 ▶ $country
Branch: 2 branches
BranchTrueFalseTotal
defined $country ? : 1 1 2
defined $cc ? : 1 0 1
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
BranchTrueFalseTotal
if (defined $org) { } 1 1 2
121  
122 2 ▶ if($cc eq 'nl')
Branch: 1 branch
BranchTrueFalseTotal
if ($cc eq 'nl') { } 2 0 2
123 2 ▶ { $pc = "$1 ".uc($2)." " if defined $pc && $pc =~ m/(\d{4})\s*([a-zA-Z]{2})/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $pc and $pc =~ /(\d{4})\s*([a-zA-Z]{2})/ 2 0 2
Condition33%1/3
defined $pc and $pc =~ /(\d{4})\s*([a-zA-Z]{2})/
!ll&&!rl&&r
002
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})/
ABresult
0X0
100
111
124 2 return "$org$address\n$pc$city$country\n";
125 }
126 else
127 0 ▶ { $state ||= '';
Condition0%0/2
$state ||= ""
l!l
00
MC/DC0%0/1
$state ||= ""
$state
Truth table0%0/2
A
A= $state
Aresult
11
00
128 0 return "$org$address\n$city$state$country\n$pc";
129 }
130 }
131  
132 2 1;
133  
« User/Identity/Collection.pm ↑ Summary User/Identity/Archive.pm »