GeoIP2/Role/Model/HasSubdivisions.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 97.8% 46 / 47 CC 2 SCAR 1.8
CC
2
Cov
100%
_build_most_specific_subdivision
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« GeoIP2/Role/Model/Location.pm ↑ Summary GeoIP2/Error/Generic.pm »
1 package GeoIP2::Role::Model::HasSubdivisions;
2 4 $GeoIP2::Role::Model::HasSubdivisions::VERSION = '0.050000';
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use GeoIP2::Record::Subdivision;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use GeoIP2::Types qw( ArrayRef object_isa_type );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Sub::Quote qw( quote_sub );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 with 'GeoIP2::Role::HasLocales';
13  
14 4 has _raw_subdivisions => (
15 is => 'ro',
16 isa => ArrayRef,
17 init_arg => 'subdivisions',
18 lazy => 1,
19 default => quote_sub(q{ [] }),
20 );
21  
22 4 has _subdivisions => (
23 is => 'ro',
24 isa => ArrayRef,
25 init_arg => undef,
26 lazy => 1,
27 builder => '_build_subdivisions',
28 );
29  
30 4 has most_specific_subdivision => (
31 is => 'ro',
32 isa => quote_sub(
33 q{ GeoIP2::Types::object_isa_type( $_[0], 'GeoIP2::Record::Subdivision' ) },
34 ),
35 init_arg => undef,
36 lazy => 1,
37 builder => '_build_most_specific_subdivision',
38 );
39  
40 sub subdivisions {
41 10 ▶ return @{ $_[0]->_subdivisions() };
Subroutine subdivisions: called CC=1 SCAR=0.0
Pod undocumented
42 }
43  
44 sub _build_subdivisions {
45 4 ▶ my $self = shift;
Subroutine _build_subdivisions: called CC=1 SCAR=0.0
46  
47 return [
48 map {
49 GeoIP2::Record::Subdivision->new(
50 2 %{$_},
51 locales => $self->locales(),
52 );
53 4 } @{ $self->_raw_subdivisions() }
54 ];
55 }
56  
57 sub _build_most_specific_subdivision {
58 4 ▶ my $self = shift;
Subroutine _build_most_specific_subdivision: called CC=2 SCAR=6.9
59  
60 4 my @subdivisions = $self->subdivisions();
61 4 ▶ return $subdivisions[-1] if @subdivisions;
Branch: 1 branch
BranchTrueFalseTotal
if @subdivisions 2 2 4
62  
63 2 return GeoIP2::Record::Subdivision->new(
64 locales => $self->locales(),
65 );
66 }
67  
68 4 1;
« GeoIP2/Role/Model/Location.pm ↑ Summary GeoIP2/Error/Generic.pm »