blib/lib/Rose/HTML/Text.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 10 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 93.3% 14 / 15 Podpod 100% 8 / 8 totaltotal 94.3% 67 / 71 CC 7 SCAR 6.1
CC
7
Cov
94%
children
3.2
text
3.0
__ANON__
2.0
CRAP 1.8
« blib/lib/Rose/HTML/Form/Field/DateTime/EndDate.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/OnOff.pm »
1 package Rose::HTML::Text;
2  
3 43 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 43 ▶use base 'Rose::HTML::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 43 ▶use Rose::HTML::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 43 our $VERSION = '0.602';
10  
11 43 __PACKAGE__->valid_html_attrs([]);
12  
13 use overload
14 43 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
15 92 ▶ '""' => sub { shift->html },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 1239 ▶ 'bool' => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
17 0 ▶ '0+' => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 43 fallback => 1,
19 43 );
20  
21 # XXX: When Class::XSAccessor is installed, the (apparent) combination of
22 # XXX: overload and Rose::Object::MakeMethods::Generic's method creation
23 # XXX: for plain scalar attributes causes things to go awry and tests to
24 # XXX" fail (e.g., t/text.t)
25 # use Rose::Object::MakeMethods::Generic
26 # (
27 # { override_existing => 1 },
28 # scalar =>
29 # [
30 # 'html',
31 # ],
32 # );
33  
34 # XXX: Do it the old-fashioned way (see comments above)
35 sub html
36 2810 ▶{
Subroutine html: called CC=2 SCAR=6.9
Pod documented
37 2810 my($self) = shift;
38 2810 ▶ return $self->{'html'} = shift if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 826 1984 2810
39 1984 return $self->{'html'};
40 }
41  
42 862 ▶sub html_tag { shift->html(@_) }
Subroutine html_tag: called CC=1 SCAR=0.0
Pod documented
43 191 ▶sub xhtml_tag { shift->xhtml(@_) }
Subroutine xhtml_tag: called CC=1 SCAR=0.0
Pod documented
44  
45 193 ▶sub xhtml { shift->html(@_) }
Subroutine xhtml: called CC=1 SCAR=0.0
Pod documented
46  
47 sub init
48 611 ▶{
Subroutine init: called CC=2 SCAR=6.9
Pod documented
49 611 my($self) = shift;
50 611 ▶ @_ = (text => @_) if(@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 1 610 611
51 611 $self->SUPER::init(@_);
52 }
53  
54 sub text
55 410 ▶{
Subroutine text: called CC=3 SCAR=11.0
Pod documented
56 410 my($self) = shift;
57 410 local $^W = 0; # XXX: Using a sledgehammer here due to possible stringification overloading on $_[0]
58 410 ▶ $self->html(defined $_[0] ? Rose::HTML::Util::escape_html(@_) : undef) if(@_);
Branch: 2 branches
BranchTrueFalseTotal
if @_ 409 1 410
defined $_[0] ? : 234 175 409
59 410 return Rose::HTML::Util::unescape_html($self->html);
60 }
61  
62 sub children
63 3 ▶{
Subroutine children: called CC=3 SCAR=11.7
Pod documented
64 3 my($self) = shift;
65 3 ▶ Carp::croak ref($self), " objects cannot have children()" if(@_ > 1);
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 3 3
66 3 ▶ return wantarray ? () : [];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 0 3
67 }
68  
69 5 ▶sub push_children { Carp::croak ref($_[0]), " objects cannot have children()" }
Subroutine push_children: called CC=1 SCAR=0.0
Pod documented
70 43 *unshift_children = \&push_children;
71  
72 43 1;
73  
74 __END__
« blib/lib/Rose/HTML/Form/Field/DateTime/EndDate.pm ↑ Summary blib/lib/Rose/HTML/Form/Field/OnOff.pm »