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

filter: Statementstmt 75.2% 73 / 97 Branchbran 45.0% 18 / 40 Conditioncond 8.3% 1 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 86.9% 20 / 23 Podpod 11.1% 1 / 9 totaltotal 59.7% 113 / 189 CC 25 SCAR 21.9
CC
25
Cov
62%
localizer
18.7
locale
18.7
default_localizer
12.0
CRAP 8.9
« blib/lib/Rose/HTML/Form/Field.pm ↑ Summary blib/lib/Rose/HTML/Object/Localized.pm »
1 package Rose::HTML::Object::Error;
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 Clone::PP();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 43 ▶use Scalar::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 43 ▶use base 'Rose::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 43 ▶use Rose::HTML::Object::Errors qw(CUSTOM_ERROR);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 43 our $VERSION = '0.606';
14  
15 #our $Debug = 0;
16  
17 use overload
18 43 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
19 43 ▶ '""' => sub { no warnings 'uninitialized'; shift->message . '' },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
20 542 ▶ 'bool' => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
21 0 ▶ '0+' => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 43 fallback => 1,
23 43 );
24  
25 use Rose::Class::MakeMethods::Generic
26 43 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 43 inheritable_scalar =>
28 [
29 '_default_localizer',
30 'default_locale',
31 ],
32 43 );
33  
34 use Rose::HTML::Object::MakeMethods::Localization
35 43 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
36 43 localized_message =>
37 [
38 'message',
39 ],
40 43 );
41  
42 43 __PACKAGE__->default_locale('en');
43  
44 0 ▶sub generic_object_class { 'Rose::HTML::Object' }
Subroutine generic_object_class: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 43 ▶sub as_string { no warnings 'uninitialized'; "$_[0]" }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine as_string: called CC=1 SCAR=0.0
Pod undocumented
47  
48 sub parent
49 646 ▶{
Subroutine parent: called CC=2 SCAR=6.9
Pod undocumented
50 646 my($self) = shift;
51 646 ▶ return Scalar::Util::weaken($self->{'parent'} = shift) if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 140 506 646
52 506 return $self->{'parent'};
53 }
54  
55 sub localizer
56 187 ▶{
Subroutine localizer: called CC=8 SCAR=29.3
Pod undocumented
57 187 my($invocant) = shift;
58  
59 # Called as object method
60 187 ▶ if(my $class = ref $invocant)
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = ref $invocant) { } 187 0 187
61 {
62 187 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 187 187
63 {
64 0 return $invocant->{'localizer'} = shift;
65 }
66  
67 187 my $localizer = $invocant->{'localizer'};
68  
69 187 ▶ unless($localizer)
Branch: 1 branch
BranchTrueFalseTotal
unless ($localizer) 187 0 187
70 {
71 187 ▶ if(my $parent = $invocant->parent)
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $invocant->parent) { } 187 0 187
72 {
73 187 ▶ if(my $localizer = $parent->localizer)
Branch: 1 branch
BranchTrueFalseTotal
if (my $localizer = $parent->localizer) 187 0 187
74 {
75 187 return $localizer;
76 }
77 }
78 0 else { return $class->default_localizer }
79 }
80  
81 0 ▶ return $localizer || $class->default_localizer;
Condition0%0/3
$localizer || $class->default_localizer
l!l&&r!l&&!r
000
MC/DC0%0/2
$localizer || $class->default_localizer
$localizer $class->default_localizer
Truth table0%0/3
A || B
A= $localizerB= $class->default_localizer
ABresult
1X1
011
000
82 }
83 else # Called as class method
84 {
85 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
86 {
87 0 return $invocant->default_localizer(shift);
88 }
89  
90 0 return $invocant->default_localizer;
91 }
92 }
93  
94 sub default_localizer
95 0 ▶{
Subroutine default_localizer: not called CC=3 SCAR=24.8
Pod undocumented
96 0 my($class) = shift;
97  
98 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
99 {
100 0 return $class->_default_localizer(@_);
101 }
102  
103 0 ▶ if(my $localizer = $class->_default_localizer)
Branch: 1 branch
BranchTrueFalseTotal
if (my $localizer = $class->_default_localizer) 0 0 0
104 {
105 0 return $localizer;
106 }
107  
108 0 return $class->_default_localizer($class->generic_object_class->localizer);
109 }
110  
111 sub locale
112 187 ▶{
Subroutine locale: called CC=8 SCAR=29.3
Pod undocumented
113 187 my($invocant) = shift;
114  
115 # Called as object method
116 187 ▶ if(my $class = ref $invocant)
Branch: 1 branch
BranchTrueFalseTotal
if (my $class = ref $invocant) { } 187 0 187
117 {
118 187 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 187 187
119 {
120 0 return $invocant->{'locale'} = shift;
121 }
122  
123 187 my $locale = $invocant->{'locale'};
124  
125 187 ▶ unless($locale)
Branch: 1 branch
BranchTrueFalseTotal
unless ($locale) 187 0 187
126 {
127 187 ▶ if(my $parent = $invocant->parent)
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $invocant->parent) { } 187 0 187
128 {
129 187 ▶ if(my $locale = $parent->locale)
Branch: 1 branch
BranchTrueFalseTotal
if (my $locale = $parent->locale) 187 0 187
130 {
131 187 return $locale;
132 }
133 }
134 0 else { return $class->default_locale }
135 }
136  
137 0 ▶ return $locale || $class->default_locale;
Condition0%0/3
$locale || $class->default_locale
l!l&&r!l&&!r
000
MC/DC0%0/2
$locale || $class->default_locale
$locale $class->default_locale
Truth table0%0/3
A || B
A= $localeB= $class->default_locale
ABresult
1X1
011
000
138 }
139 else # Called as class method
140 {
141 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
142 {
143 0 return $invocant->default_locale(shift);
144 }
145  
146 0 return $invocant->default_locale;
147 }
148 }
149  
150 sub clone
151 1 ▶{
Subroutine clone: called CC=1 SCAR=0.0
Pod undocumented
152 1 my($self) = shift;
153 1 my $clone = Clone::PP::clone($self);
154 1 $clone->parent(undef);
155 1 return $clone;
156 }
157  
158 sub id
159 177 ▶{
Subroutine id: called CC=5 SCAR=16.7
Pod documented
160 177 my($self) = shift;
161  
162 177 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 107 70 177
163 {
164 107 return $self->{'id'} = shift;
165 }
166  
167 70 my $id = $self->{'id'};
168  
169 70 ▶ return $id if(defined $id);
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 55 15 70
170  
171 15 my $msg = $self->message;
172 15 ▶ return CUSTOM_ERROR if($msg && $msg->is_custom);
Branch: 1 branch
BranchTrueFalseTotal
if $msg and $msg->is_custom 15 0 15
Condition33%1/3
$msg and $msg->is_custom
!ll&&!rl&&r
0015
MC/DC0%0/2
$msg and $msg->is_custom
$msg $msg->is_custom
Truth table33%1/3
A and B
A= $msgB= $msg->is_custom
ABresult
0X0
100
111
173 0 return undef;
174 }
175  
176 sub is_custom
177 3 ▶{
Subroutine is_custom: called CC=4 SCAR=21.1
Pod undocumented
178 3 my($self) = shift;
179  
180 3 my $id = $self->id;
181  
182 3 ▶ unless(defined $id)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 3 3
183 {
184 0 my $msg = $self->message;
185  
186 0 ▶ return 1 if($msg && $msg->is_custom);
Branch: 1 branch
BranchTrueFalseTotal
if $msg and $msg->is_custom 0 0 0
Condition0%0/3
$msg and $msg->is_custom
!ll&&!rl&&r
000
MC/DC0%0/2
$msg and $msg->is_custom
$msg $msg->is_custom
Truth table0%0/3
A and B
A= $msgB= $msg->is_custom
ABresult
0X0
100
111
187 0 return undef;
188 }
189  
190 3 return $id == CUSTOM_ERROR;
191 }
192  
193 43 1;
194  
195 __END__
« blib/lib/Rose/HTML/Form/Field.pm ↑ Summary blib/lib/Rose/HTML/Object/Localized.pm »