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

filter: Statementstmt 81.8% 63 / 77 Branchbran 75.0% 15 / 20 Conditioncond 50.0% 5 / 10 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 80.0% 16 / 20 Podpod 28.5% 2 / 7 totaltotal 73.5% 103 / 140 CC 16 SCAR 19.1
CC
16
Cov
78%
args
16.6
text
3.1
__ANON__
2.0
CRAP 6.8
« blib/lib/Rose/HTML/Util.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Set.pm »
1 package Rose::HTML::Object::Message;
2  
3 44 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 44 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 44 ▶use Clone::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 44 ▶use Scalar::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 44 ▶use Rose::HTML::Object::Messages qw(CUSTOM_MESSAGE);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 44 ▶use base 'Rose::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 44 our $VERSION = '0.606';
14  
15 #our $Debug = 0;
16  
17 use overload
18 44 ▶(
Subroutine BEGIN: called CC=1 SCAR=1.2
19 0 ▶ '""' => sub { shift->text },
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 ▶ 'bool' => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 ▶ '0+' => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 44 fallback => 1,
23 44 );
24  
25 use Rose::Object::MakeMethods::Generic
26 44 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 44 scalar =>
28 [
29 'id',
30 'variant',
31 ],
32 44 );
33  
34 44 ▶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
35  
36 sub init
37 859 ▶{
Subroutine init: called CC=2 SCAR=6.9
Pod documented
38 859 my($self) = shift;
39 859 ▶ @_ = (text => @_) if(@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 28 831 859
40 859 $self->SUPER::init(@_);
41 }
42  
43 sub args
44 2663 ▶{
Subroutine args: called CC=12 SCAR=28.1
Pod undocumented
45 2663 my($self) = shift;
46  
47 2663 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 459 2204 2663
48 {
49 459 my %args;
50  
51 459 ▶ if(@_ == 1 && ref $_[0] eq 'ARRAY')
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'ARRAY') { } 400 59 459
elsif (@_ == 1 and ref $_[0] eq 'HASH') { } 59 0 59
Condition66%2/3
@_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
059400
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "ARRAY"
@_ == 1 ref $_[0] eq "ARRAY"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
52 {
53 400 my $i = 1;
54 400 %args = (map { $i++ => $_ } @{$_[0]});
55 }
56 ▶ elsif(@_ == 1 && ref $_[0] eq 'HASH')
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
0059
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
57 {
58 59 %args = %{$_[0]};
59  
60 59 my $i = 1;
61  
62 59 foreach my $key (sort keys %args)
63 {
64 84 ▶ $args{$i} = $args{$key} unless(exists $args{$i});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{$i} 84 0 84
65 84 $i++;
66 }
67 }
68 else
69 {
70 0 my $i = 1;
71 0 %args = map { $i++ => $_ } @_;
72 }
73  
74 459 $self->{'args'} = \%args;
75  
76 0 ▶ return wantarray ? %{$self->{'args'}} : $self->{'args'};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 459 459
77 }
78  
79 0 ▶ return wantarray ? %{$self->{'args'} || {}} : ($self->{'args'} ||= {});
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2204 2204
Condition50%2/4
$self->{'args'} || {}
l!l
00
$self->{"args"} ||= {}
l!l
2099105
MC/DC0%0/1
$self->{'args'} || {}
$self->{'args'}
MC/DC100%1/1
$self->{"args"} ||= {}
$self->{"args"}
Truth table0%0/2
A
A= $self->{'args'}
Aresult
11
00
Truth table100%2/2
A
A= $self->{"args"}
Aresult
11
00
80 }
81  
82 sub parent
83 8165 ▶{
Subroutine parent: called CC=2 SCAR=6.9
Pod undocumented
84 8165 my($self) = shift;
85 8165 ▶ return Scalar::Util::weaken($self->{'parent'} = shift) if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1204 6961 8165
86 6961 return $self->{'parent'};
87 }
88  
89 sub clone
90 0 ▶{
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
91 0 my($self) = shift;
92 0 my $clone = Clone::PP::clone($self);
93 0 $clone->parent(undef);
94 0 return $clone;
95 }
96  
97 sub text
98 2254 ▶{
Subroutine text: called CC=3 SCAR=11.4
Pod documented
99 2254 my($self) = shift;
100  
101 2254 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 399 1855 2254
102 {
103 399 ▶ if(UNIVERSAL::isa($_[0], __PACKAGE__))
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($_[0], __PACKAGE__)) 0 399 399
104 {
105 0 $self->id($_[0]->id);
106 0 return $self->{'text'} = $_[0]->text;
107 }
108  
109 399 $self->id(CUSTOM_MESSAGE);
110 399 return $self->{'text'} = $_[0];
111 }
112  
113 1855 return $self->{'text'};
114 }
115  
116 44 ▶sub is_custom { no warnings; shift->id == CUSTOM_MESSAGE }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine is_custom: called CC=1 SCAR=0.0
Pod undocumented
117  
118 44 1;
119  
120 __END__
« blib/lib/Rose/HTML/Util.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/Set.pm »