OO/Role/DomainAndCategory.pm

filter: Statementstmt 94.7% 54 / 57 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 7 / 7 totaltotal 91.6% 77 / 84 CC 5 SCAR 4.3
CC
5
Cov
89%
end_d
2.2
end_c
2.1
begin_d
2.0
CRAP 1.5
« OO/Plugin/Expand/Gettext/DomainAndCategory.pm ↑ Summary OO/Plugin/Expand/Maketext.pm »
1 package Locale::TextDomain::OO::Role::DomainAndCategory; ## no critic (TidyCode)
2
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use Carp qw(confess cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Locale::TextDomain::OO::Translator;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 9 our $VERSION = '1.030';
10
11 9 requires qw(
12 category
13 domain
14 );
15
16 9 our ( @domains, @categories ); ## no critic (PackageVars)
17
18 2 ▶sub callback_scope {
Subroutine callback_scope: called CC=1 SCAR=0.0
Pod documented
19 2 my ( $self, $callback ) = @_;
20
21 2 local @domains = @domains; ## no critic (LocalVars)
22 2 local @categories = @categories; ## no critic (LocalVars)
23 2 my $domain = $self->domain;
24 2 my $category = $self->category;
25 2 my $translation = $callback->();
26 2 $self->domain($domain);
27 2 $self->category($category);
28
29 2 return $translation;
30 }
31
32 10 ▶sub begin_d {
Subroutine begin_d: called CC=2 SCAR=7.0
Pod documented
33 10 my ($self, $domain) = @_;
34
35 10 ▶ defined $domain
Branch: 1 branch
BranchTrueFalseTotal
defined $domain or confess("Domain is not defined") 10 0 10
36 or confess 'Domain is not defined';
37 10 push
38 @domains,
39 $self->domain;
40 10 $self->domain($domain);
41
42 10 return $self;
43 }
44
45 8 ▶sub begin_c {
Subroutine begin_c: called CC=2 SCAR=7.0
Pod documented
46 8 my ($self, $category) = @_;
47
48 8 ▶ defined $category
Branch: 1 branch
BranchTrueFalseTotal
defined $category or confess("Category is not defined") 8 0 8
49 or confess 'Category is not defined';
50 8 push
51 @categories,
52 $self->category;
53 8 $self->category($category);
54
55 8 return $self;
56 }
57
58 4 ▶sub begin_dc {
Subroutine begin_dc: called CC=1 SCAR=0.0
Pod documented
59 4 my ($self, $domain, $category) = @_;
60
61 4 $self->begin_d($domain);
62 4 $self->begin_c($category);
63
64 4 return $self;
65 }
66
67 8 ▶sub end_d {
Subroutine end_d: called CC=2 SCAR=7.9
Pod documented
68 8 my $self = shift;
69
70 8 ▶ if ( ! @domains ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@Locale::TextDomain::OO::Role::DomainAndCategory::domains) 0 8 8
71 0 cluck 'Tried to get the domain from stack but no domain is not stored';
72 0 return $self;
73 }
74 8 $self->domain( pop @domains );
75
76 8 return $self;
77 }
78
79 6 ▶sub end_c {
Subroutine end_c: called CC=2 SCAR=7.4
Pod documented
80 6 my $self = shift;
81
82 6 ▶ if ( ! @categories ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@Locale::TextDomain::OO::Role::DomainAndCategory::categories) 0 6 6
83 0 cluck 'Tried to get the category from stack but no category is stored',
84 return $self;
85 }
86 6 $self->category( pop @categories );
87
88 6 return $self;
89 }
90
91 4 ▶sub end_dc {
Subroutine end_dc: called CC=1 SCAR=0.0
Pod documented
92 4 my $self = shift;
93
94 4 $self->end_d;
95 4 $self->end_c;
96
97 4 return $self;
98 }
99
100 9 1;
101
102 __END__
« OO/Plugin/Expand/Gettext/DomainAndCategory.pm ↑ Summary OO/Plugin/Expand/Maketext.pm »