GeoIP2/Role/Model/HasSubdivisions.pm

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