GeoIP2/Role/Record/HasNames.pm

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