| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||
| 62 | 187 | ▶ | if(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||
| 64 | 0 | return $invocant->{'localizer'} = shift; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 187 | my $localizer = $invocant->{'localizer'}; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 187 | ▶ | unless($localizer) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||
| 71 | 187 | ▶ | if(my $parent = $invocant->parent) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||
| 73 | 187 | ▶ | if(my $localizer = $parent->localizer) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$localizer || $class->default_localizer
$localizer
$class->default_localizer
Truth table0%0/3
A || B
A= $localizerB= $class->default_localizer
| |||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | else # Called as class method | ||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||
| 100 | 0 | return $class->_default_localizer(@_); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if(my $localizer = $class->_default_localizer) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||
| 118 | 187 | ▶ | if(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||
| 120 | 0 | return $invocant->{'locale'} = shift; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 187 | my $locale = $invocant->{'locale'}; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 187 | ▶ | unless($locale) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||
| 127 | 187 | ▶ | if(my $parent = $invocant->parent) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||
| 129 | 187 | ▶ | if(my $locale = $parent->locale) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$locale || $class->default_locale
$locale
$class->default_locale
Truth table0%0/3
A || B
A= $localeB= $class->default_locale
| |||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | else # Called as class method | ||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 15 | my $msg = $self->message; | |||||||||||||||||||||||||||
| 172 | 15 | ▶ | return CUSTOM_ERROR if($msg && $msg->is_custom); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$msg and $msg->is_custom
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||
| 184 | 0 | my $msg = $self->message; | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | return 1 if($msg && $msg->is_custom); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$msg and $msg->is_custom
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
| |||||||||||||||||||||||||||||
| 187 | 0 | return undef; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 3 | return $id == CUSTOM_ERROR; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 43 | 1; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | __END__ | ||||||||||||||||||||||||||||