OO/Plugin/Language/LanguageOfLanguages.pm

filter: Statementstmt 90.0% 36 / 40 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod n/a totaltotal 86.7% 46 / 53 CC 5 SCAR 10.5
CC
5
Cov
86%
_trigger_languages
5.6
__ANON__
2.0
BEGIN
1.0
CRAP 2.9
« OO/Plugin/Expand/Gettext/Loc.pm ↑ Summary OO/Lexicon/File/PO.pm »
1 package Locale::TextDomain::OO::Plugin::Language::LanguageOfLanguages; ## no critic (Tidy Code)
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Locale::TextDomain::OO::Singleton::Lexicon;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Locale::TextDomain::OO::Util::JoinSplitLexiconKeys;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use MooX::Types::MooseLike::Base qw(Str ArrayRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 2 our $VERSION = '1.014';
12
13 2 with qw(
14 Locale::TextDomain::OO::Role::Logger
15 );
16
17 2 requires qw(
18 language
19 category
20 domain
21 project
22 );
23
24 has languages => (
25 is => 'rw',
26 isa => ArrayRef[Str],
27 trigger => 1,
28 lazy => 1,
29 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 2 );
31
32 2 ▶sub _trigger_languages { ## no critic (UnusedPrivateSubroutines)
Subroutine _trigger_languages: called CC=5 SCAR=17.3
33 2 my ($self, $languages) = @_;
34
35 2 my $lexicon = Locale::TextDomain::OO::Singleton::Lexicon->instance->data;
36 2 for my $language ( @{$languages} ) {
37 7 for my $key ( keys %{$lexicon} ) {
38 9 my $lexicon_key = Locale::TextDomain::OO::Util::JoinSplitLexiconKeys
39 ->instance
40 ->join_lexicon_key({
41 language => lc $language,
42 category => $self->category,
43 domain => $self->domain,
44 project => $self->project,
45 });
46 9 ▶ if ( $key eq $lexicon_key ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq $lexicon_key) 2 7 9
47 2 $self->language( lc $language );
48 2 return;
49 }
50 }
51 }
52 0 $self->language('i-default');
53 0 ▶ $self->logger
Branch: 1 branch
BranchTrueFalseTotal
$self->logger and $self->logger->("Fallback language \"i-default\" selected.", {"object", $self, "type", "warn", "event", "language,selection,fallback"}) 0 0 0
54 and $self->logger->(
55 'Fallback language "i-default" selected.',
56 {
57 object => $self,
58 type => 'warn',
59 event => 'language,selection,fallback',
60 },
61 );
62
63 0 return;
64 }
65
66 2 1;
67
68 __END__
« OO/Plugin/Expand/Gettext/Loc.pm ↑ Summary OO/Lexicon/File/PO.pm »