blib/lib/Rose/HTML/Object/Localized.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 83.3% 15 / 18 Conditioncond 50.0% 6 / 12 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 78.6% 70 / 89 CC 15 SCAR 20.2
CC
15
Cov
85%
locale
12.1
localizer
5.3
BEGIN
1.0
CRAP 7.5
« blib/lib/Rose/HTML/Object/Error.pm ↑ Summary blib/lib/Rose/HTML/Object/Message/Localized.pm »
1 package Rose::HTML::Object::Localized;
2  
3 43 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 43 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 43 ▶use Rose::HTML::Object::Message::Localizer;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 43 ▶use base 'Rose::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 43 our $VERSION = '0.600';
11  
12 #our $Debug = 0;
13  
14 use Rose::HTML::Object::MakeMethods::Localization
15 43 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
16 43 localized_errors =>
17 [
18 'errors',
19 ],
20 43 );
21  
22 use Rose::Class::MakeMethods::Generic
23 43 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
24 43 inheritable_scalar =>
25 [
26 'default_localizer',
27 'default_locale',
28 ],
29 43 );
30  
31 sub localizer
32 230 ▶{
Subroutine localizer: called CC=5 SCAR=16.7
Pod undocumented
33 230 my($invocant) = shift;
34  
35 # Called as object method
36 230 ▶ if(my $class = ref $invocant)
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = ref $invocant) { } 209 21 230
37 {
38 209 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 209 209
39 {
40 0 return $invocant->{'localizer'} = shift;
41 }
42  
43 209 ▶ return $invocant->{'localizer'} || $class->default_localizer;
Condition33%1/3
$invocant->{'localizer'} || $class->default_localizer
l!l&&r!l&&!r
02090
MC/DC0%0/2
$invocant->{'localizer'} || $class->default_localizer
$invocant->{'localizer'} $class->default_localizer
Truth table33%1/3
A || B
A= $invocant->{'localizer'}B= $class->default_localizer
ABresult
1X1
011
000
44 }
45 else # Called as class method
46 {
47 21 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 19 21
48 {
49 2 return $invocant->default_localizer(@_);
50 }
51  
52 19 return $invocant->default_localizer
53 }
54 }
55  
56 sub locale
57 94 ▶{
Subroutine locale: called CC=11 SCAR=24.9
Pod undocumented
58 94 my($invocant) = shift;
59  
60 # Called as an object method
61 94 ▶ if(my $class = ref $invocant)
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = ref $invocant) { } 93 1 94
62 {
63 93 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 15 78 93
64 {
65 15 return $invocant->{'locale'} = shift;
66 }
67  
68 78 ▶ return $invocant->{'locale'} if($invocant->{'locale'});
Branch: 1 branch
BranchTrueFalseTotal
if $invocant->{"locale"} 31 47 78
69  
70 47 foreach my $parent_name (qw(parent_group parent_field parent_form parent))
71 {
72 184 ▶ if($invocant->can($parent_name) && (my $parent = $invocant->$parent_name()))
Branch: 1 branch
BranchTrueFalseTotal
if ($invocant->can($parent_name) and my $parent = $invocant->$parent_name) 4 180 184
Condition100%3/3
$invocant->can($parent_name) and my $parent = $invocant->$parent_name
!ll&&!rl&&r
661144
MC/DC100%2/2
$invocant->can($parent_name) and my $parent = $invocant->$parent_name
$invocant->can($parent_name) my $parent = $invocant->$parent_name
Truth table100%3/3
A and B
A= $invocant->can($parent_name)B= my $parent = $invocant->$parent_name
ABresult
0X0
100
111
73 {
74 4 my $locale = $parent->locale;
75 4 ▶ return $locale if(defined $locale);
Branch: 1 branch
BranchTrueFalseTotal
if defined $locale 4 0 4
76 }
77 }
78  
79 43 ▶ return $invocant->localizer->locale || $invocant->localizer->default_locale;
Condition33%1/3
$invocant->localizer->locale || $invocant->localizer->default_locale
l!l&&r!l&&!r
4300
MC/DC0%0/2
$invocant->localizer->locale || $invocant->localizer->default_locale
$invocant->localizer->locale $invocant->localizer->default_locale
Truth table33%1/3
A || B
A= $invocant->localizer->localeB= $invocant->localizer->default_locale
ABresult
1X1
011
000
80 }
81 else # Called as a class method
82 {
83 1 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
84 {
85 0 return $invocant->default_locale(shift);
86 }
87  
88 1 ▶ return $invocant->localizer->locale || $invocant->default_locale;
Condition33%1/3
$invocant->localizer->locale || $invocant->default_locale
l!l&&r!l&&!r
100
MC/DC0%0/2
$invocant->localizer->locale || $invocant->default_locale
$invocant->localizer->locale $invocant->default_locale
Truth table33%1/3
A || B
A= $invocant->localizer->localeB= $invocant->default_locale
ABresult
1X1
011
000
89 }
90 }
91  
92 43 1;
« blib/lib/Rose/HTML/Object/Error.pm ↑ Summary blib/lib/Rose/HTML/Object/Message/Localized.pm »