StreetMapLink/Google.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 50.0% 3 / 6 Conditioncond 41.6% 5 / 12 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 85.7% 6 / 7 Podpod 75.0% 3 / 4 totaltotal 71.4% 45 / 63 CC 10 SCAR 21.5
CC
10
Cov
77%
new
13.1
Priority
2.0
BEGIN
1.0
CRAP 8.6
« StreetMapLink/MapQuest.pm ↑ Summary StreetMapLink.pm »
1 package WebService::StreetMapLink::Google;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Geography::States;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use base 'WebService::StreetMapLink';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 __PACKAGE__->RegisterSubclass(99);
9  
10  
11 5 my @Accents = ( [ qr/[\xE0-\xE2]/ => 'a' ],
12 [ qr/[\xE8-\xEA]/ => 'e' ],
13 [ qr/\xE7/ => 'c' ],
14 [ qr/\xF4/ => 'o' ],
15 );
16  
17 sub Countries
18 5 ▶{
Subroutine Countries: called CC=1 SCAR=0.0
Pod documented
19 5 return ( qw( australia austria belgium
20 canada denmark
21 france germany hungary
22 italy netherlands
23 singapore spain
24 sweden switzerland
25 uk usa
26 ),
27 'czech republic',
28 'puerto rico'
29 );
30 }
31  
32 0 ▶sub Priority { 99 }
Subroutine Priority: not called CC=1 SCAR=6.9
Pod undocumented
33  
34 sub new
35 5 ▶{
Subroutine new: called CC=10 SCAR=25.7
Pod documented
36 5 my $class = shift;
37 5 my %p = @_;
38  
39 5 local $_;
40 # remove accents from state names like Quebec or google gets upset
41 5 for ( grep { defined } values %p )
42 {
43 24 foreach my $p (@Accents)
44 {
45 96 s/$p->[0]/$p->[1]/g;
46 }
47 }
48  
49 return
50 unless ( defined $p{address}
51 &&
52 ( ( defined $p{city}
53 && ( defined $p{state} || $p{country} ne 'usa' )
54 )
55 ||
56 defined $p{postal_code}
57 )
58 5 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"address"} and defined $p{"city"} && (defined $p{"state"} || $p{"country"} ne "usa") || defined $p{"postal_code"} 0 5 5
Condition41%5/12
defined $p{"address"} and defined $p{"city"} && (defined $p{"state"} || $p{"country"} ne "usa") || defined $p{"postal_code"}
!ll&&!rl&&r
005
defined $p{"city"} and defined $p{"state"} || $p{"country"} ne "usa" or defined $p{"postal_code"}
l!l&&r!l&&!r
500
defined $p{"city"} and defined $p{"state"} || $p{"country"} ne "usa"
!ll&&!rl&&r
005
defined $p{"state"} or $p{"country"} ne "usa"
l!l&&r!l&&!r
410
MC/DC0%0/5
defined $p{"address"} and defined $p{"city"} && (defined $p{"state"} || $p{"country"} ne "usa") || defined $p{"postal_code"}
defined $p{"address"} defined $p{"city"} defined $p{"state"} $p{"country"} ne "usa" defined $p{"postal_code"}
Truth table28%2/7
A and B and C or D or E
A= defined $p{"address"}B= defined $p{"city"}C= defined $p{"state"}D= $p{"country"} ne "usa"E= defined $p{"postal_code"}
ABCDEresult
0XXXX0
10XX00
110000
111XX1
1101X1
10XX11
110011
59  
60 5 ▶ return if $p{address} =~ /p\.?o\.\s+box/i;
Branch: 1 branch
BranchTrueFalseTotal
if $p{"address"} =~ /p\.?o\.\s+box/i 0 5 5
61  
62 $p{postal_code} =~ s/-\d{4}$//
63 5 ▶ if defined $p{postal_code};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p{"postal_code"} 5 0 5
64  
65 my $q =
66 ( join ',',
67 25 grep { defined }
68 5 map { $p{$_} } qw( address city state postal_code country )
69 );
70  
71 5 return bless { host => 'maps.google.com',
72 path => '/maps',
73 query => { q => $q }
74 }, $class;
75 }
76  
77 1 ▶sub service_name { 'Google Maps' }
Subroutine service_name: called CC=1 SCAR=0.0
Pod documented
78  
79  
80 5 1;
81  
82 __END__
« StreetMapLink/MapQuest.pm ↑ Summary StreetMapLink.pm »