OO/Plugin/Expand/Gettext/Loc.pm

filter: Statementstmt 93.2% 55 / 59 Branchbran 69.2% 18 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 4 / 4 totaltotal 88.1% 89 / 101 CC 14 SCAR 11.5
CC
14
Cov
86%
loc_x
4.2
loc_nx
4.2
loc_px
4.2
CRAP 3.2
« OO/Plugin/Expand/Gettext.pm ↑ Summary OO/Plugin/Language/LanguageOfLanguages.pm »
1 package Locale::TextDomain::OO::Plugin::Expand::Gettext::Loc; ## no critic (TidyCode)
2
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 ▶use Locale::Utils::PlaceholderNamed;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 6 our $VERSION = '1.027';
9
10 6 requires qw(
11 translate
12 filter
13 run_filter
14 );
15
16 has expand_gettext_loc => (
17 is => 'rw',
18 5 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
19 5 return Locale::Utils::PlaceholderNamed->new;
20 },
21 6 );
22
23 8 ▶sub loc_x {
Subroutine loc_x: called CC=4 SCAR=14.5
Pod documented
24 8 my ($self, $msgid, @args) = @_;
25
26 8 my $translation = $self->translate(undef, $msgid);
27 @args and $translation = $self->expand_gettext_loc->expand_named(
28 $translation,
29 0 ▶ @args == 1 ? %{ $args[0] } : @args,
Branch: 2 branches
BranchTrueFalseTotal
@args and $translation = $self->expand_gettext_loc->expand_named($translation, @args == 1 ? %{$args[0];} : @args) 2 6 8
@args == 1 ? : 0 2 2
30 );
31 8 ▶ $self->filter
Branch: 1 branch
BranchTrueFalseTotal
$self->filter and $self->run_filter(\$translation) 0 8 8
32 and $self->run_filter(\$translation);
33
34 8 return $translation;
35 }
36
37 4 ▶sub loc_nx {
Subroutine loc_nx: called CC=4 SCAR=14.5
Pod documented
38 4 my ($self, $msgid, $msgid_plural, $count, @args) = @_;
39
40 4 my $translation = $self->translate(undef, $msgid, $msgid_plural, $count, 1);
41 @args and $translation = $self->expand_gettext_loc->expand_named(
42 $translation,
43 0 ▶ @args == 1 ? %{ $args[0] } : @args,
Branch: 2 branches
BranchTrueFalseTotal
@args and $translation = $self->expand_gettext_loc->expand_named($translation, @args == 1 ? %{$args[0];} : @args) 2 2 4
@args == 1 ? : 0 2 2
44 );
45 4 ▶ $self->filter
Branch: 1 branch
BranchTrueFalseTotal
$self->filter and $self->run_filter(\$translation) 0 4 4
46 and $self->run_filter(\$translation);
47
48 4 return $translation;
49 }
50
51 5 ▶sub loc_px {
Subroutine loc_px: called CC=4 SCAR=14.5
Pod documented
52 5 my ($self, $msgctxt, $msgid, @args) = @_;
53
54 5 my $translation = $self->translate($msgctxt, $msgid);
55 @args and $translation = $self->expand_gettext_loc->expand_named(
56 $translation,
57 0 ▶ @args == 1 ? %{ $args[0] } : @args,
Branch: 2 branches
BranchTrueFalseTotal
@args and $translation = $self->expand_gettext_loc->expand_named($translation, @args == 1 ? %{$args[0];} : @args) 1 4 5
@args == 1 ? : 0 1 1
58 );
59 5 ▶ $self->filter
Branch: 1 branch
BranchTrueFalseTotal
$self->filter and $self->run_filter(\$translation) 0 5 5
60 and $self->run_filter(\$translation);
61
62 5 return $translation;
63 }
64
65 4 ▶sub loc_npx { ## no critic (ManyArgs)
Subroutine loc_npx: called CC=4 SCAR=14.5
Pod documented
66 4 my ($self, $msgctxt, $msgid, $msgid_plural, $count, @args) = @_;
67
68 4 my $translation = $self->translate($msgctxt, $msgid, $msgid_plural, $count, 1);
69 @args and $translation = $self->expand_gettext_loc->expand_named(
70 $translation,
71 0 ▶ @args == 1 ? %{ $args[0] } : @args,
Branch: 2 branches
BranchTrueFalseTotal
@args and $translation = $self->expand_gettext_loc->expand_named($translation, @args == 1 ? %{$args[0];} : @args) 2 2 4
@args == 1 ? : 0 2 2
72 );
73 4 ▶ $self->filter
Branch: 1 branch
BranchTrueFalseTotal
$self->filter and $self->run_filter(\$translation) 0 4 4
74 and $self->run_filter(\$translation);
75
76 4 return $translation;
77 }
78
79 6 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
80 6 ▶ no warnings qw(redefine); ## no critic (NoWarnings)
Subroutine BEGIN: called CC=1 SCAR=0.0
81 6 *loc_ = \&loc_x;
82 6 *loc_n = \&loc_nx;
83 6 *loc_p = \&loc_px;
84 6 *loc_np = \&loc_npx;
85
86 # Dummy methods for string marking.
87 9 ▶ my $dummy = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
88 9 my (undef, @more) = @_;
89 9 ▶ return wantarray ? @more : $more[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 8 1 9
90 6 };
91 6 *Nloc_ = $dummy;
92 6 *Nloc_x = $dummy;
93 6 *Nloc_n = $dummy;
94 6 *Nloc_nx = $dummy;
95 6 *Nloc_p = $dummy;
96 6 *Nloc_px = $dummy;
97 6 *Nloc_np = $dummy;
98 6 *Nloc_npx = $dummy;
99 }
100
101 6 1;
102
103 __END__
« OO/Plugin/Expand/Gettext.pm ↑ Summary OO/Plugin/Language/LanguageOfLanguages.pm »