OO/Plugin/Expand/Gettext.pm

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