File Coverage

blib/lib/Locale/TextDomain/OO/Plugin/Expand/Maketext.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 6 66.6
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 45 47 95.7


line stmt bran cond sub pod time code
1             package Locale::TextDomain::OO::Plugin::Expand::Maketext; ## no critic (TidyCode)
2            
3 8     8   8118 use strict;
  8         21  
  8         245  
4 8     8   44 use warnings;
  8         20  
  8         205  
5 8     8   966 use Locale::Utils::PlaceholderMaketext;
  8         16875  
  8         202  
6 8     8   41 use Moo::Role;
  8         17  
  8         45  
7            
8             our $VERSION = '1.027';
9            
10             requires qw(
11             translate
12             filter
13             run_filter
14             );
15            
16             has expand_maketext => (
17             is => 'rw',
18             default => sub {
19             return Locale::Utils::PlaceholderMaketext->new;
20             },
21             );
22            
23             sub maketext {
24 23     23 1 8076 my ($self, $msgid, @args) = @_;
25            
26 23         91 my $translation = $self->translate(undef, $msgid);
27 23         127 $translation = $self->expand_maketext->expand_maketext(
28             $translation,
29             @args,
30             );
31 23 50       2278 $self->filter
32             and $self->run_filter(\$translation);
33            
34 23         315 return $translation;
35             }
36            
37             sub maketext_p {
38 11     11 1 46 my ($self, $msgctxt, $msgid, @args) = @_;
39            
40 11         48 my $translation = $self->translate($msgctxt, $msgid);
41 11         70 $translation = $self->expand_maketext->expand_maketext(
42             $translation,
43             @args,
44             );
45 11 50       917 $self->filter
46             and $self->run_filter(\$translation);
47            
48 11         126 return $translation;
49             }
50            
51             BEGIN {
52 8     8   4795 no warnings qw(redefine); ## no critic (NoWarnings)
  8         27  
  8         747  
53            
54             # Dummy methods for string marking.
55             my $dummy = sub {
56 11     11   40 my (undef, @more) = @_;
57 11 100       90 return wantarray ? @more : $more[0];
58 8     8   61 };
59 8         24 *Nmaketext = $dummy;
60 8         231 *Nmaketext_p = $dummy;
61             }
62            
63             1;
64            
65             __END__