GeoIP2/Role/Record/HasNames.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 44 / 44 CC 2 SCAR 1.8
CC
2
Cov
100%
_build_name
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« GeoIP2/Types.pm ↑ Summary GeoIP2/Role/Model/Location.pm »
1 package GeoIP2::Role::Record::HasNames;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 our $VERSION = '2.006002';
7  
8 12 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶use GeoIP2::Types qw( MaybeStr NameHashRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use List::Util qw( first );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use Sub::Quote qw( quote_sub );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 12 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 12 with 'GeoIP2::Role::HasLocales';
17  
18 12 has name => (
19 is => 'ro',
20 isa => MaybeStr,
21 lazy => 1,
22 builder => '_build_name',
23 );
24  
25 12 has names => (
26 is => 'ro',
27 isa => NameHashRef,
28 default => quote_sub(q{ {} }),
29 );
30  
31 15 ▶sub _build_name {
Subroutine _build_name: called CC=2 SCAR=6.9
32 15 my $self = shift;
33  
34 15 my $names = $self->names();
35  
36 15 ▶ my $lang = first { exists $names->{$_} } @{ $self->locales() };
Subroutine __ANON__: called CC=1 SCAR=0.0
37  
38 15 ▶ return unless $lang;
Branch: 1 branch
BranchTrueFalseTotal
unless $lang 3 12 15
39 12 return $names->{$lang};
40 }
41  
42 12 1;
« GeoIP2/Types.pm ↑ Summary GeoIP2/Role/Model/Location.pm »