HTML/Element.pm

filter: Statementstmt 45.5% 56 / 123 Branchbran 33.3% 14 / 42 Conditioncond 65.2% 15 / 23 MC/DCmcdc 41.6% 5 / 12 Subroutinesub 42.1% 16 / 38 Podpod 100% 4 / 4 totaltotal 45.4% 110 / 242 CC 35 SCAR 17.3
CC
35
Cov
45%
get_attr
12.0
string
12.0
get_attr
12.0
CRAP 5.7
« HTML.pm ↑ Summary
1 package YAPE::HTML::Element;
2  
3 1 $VERSION = '1.10';
4  
5  
6 64 ▶sub text { $_[0]{TEXT} }
Subroutine text: called CC=1 SCAR=0.0
Pod documented
7 55 ▶sub string { $_[0]->text }
Subroutine string: called CC=1 SCAR=0.0
Pod documented
8 65 ▶sub fullstring { $_[0]->string }
Subroutine fullstring: called CC=1 SCAR=0.0
Pod documented
9 163 ▶sub type { $_[0]{TYPE} }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
10  
11  
12 package YAPE::HTML::tag;
13  
14 87 ▶sub new {
Subroutine new: called CC=5 SCAR=18.9
15 87 my ($class, $tag, $attr, $text, $closed, $impl) = @_;
16 87 ▶ bless {
Condition50%4/8
$attr || {}
l!l
870
$text || []
l!l
870
$closed || 0
l!l
087
$impl || 0
l!l
087
MC/DC0%0/1
$attr || {}
$attr
MC/DC0%0/1
$text || []
$text
MC/DC0%0/1
$closed || 0
$closed
MC/DC0%0/1
$impl || 0
$impl
Truth table50%1/2
A
A= $attr
Aresult
11
00
Truth table50%1/2
A
A= $text
Aresult
11
00
Truth table50%1/2
A
A= $closed
Aresult
11
00
Truth table50%1/2
A
A= $impl
Aresult
11
00
17 TYPE => 'tag',
18 TAG => $tag,
19 ATTR => $attr || {},
20 TEXT => $text || [],
21 CLOSED => $closed || 0,
22 IMPLIED => $impl || 0,
23 }, $class;
24 }
25  
26 43 ▶sub string {
Subroutine string: called CC=4 SCAR=13.9
27 43 my $self = shift;
28 43 my $str = "<$self->{TAG}";
29 43 for (sort keys %{ $self->{ATTR} }) {
30 13 $str .= " $_";
31 13 ▶ if (defined $self->{ATTR}{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"ATTR"}{$_}) 13 0 13
32 13 $str .= "=" . YAPE::HTML::quote($self->{ATTR}{$_});
33 }
34 }
35 43 ▶ $str .= " /" if $self->{IMPLIED};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"IMPLIED"} 2 41 43
36 43 $str .= ">";
37 43 return $str;
38 }
39  
40 52 ▶sub fullstring {
Subroutine fullstring: called CC=9 SCAR=22.0
41 52 my $self = shift;
42 52 my ($taghash, $taglist) = ({}, []);
43 52 ▶ @$taghash{@{ $taglist = shift }} = () if ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 24 28 52
44 52 ▶ my $d = @_ ? $_[0] : -1;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 27 25 52
45 52 my $str;
46  
47 52 ▶ $str = $self->string if $d and not exists $taghash->{$self->{TAG}};
Branch: 1 branch
BranchTrueFalseTotal
if $d and not exists $$taghash{$self->{"TAG"}} 43 9 52
Condition100%3/3
$d and not exists $$taghash{$self->{"TAG"}}
!ll&&!rl&&r
7243
MC/DC100%2/2
$d and not exists $$taghash{$self->{"TAG"}}
$d not exists $$taghash{$self->{"TAG"}}
Truth table100%3/3
A and not(B)
A= $dB= not exists $$taghash{$self->{"TAG"}}
ABresult
0X0
100
111
48 $str .= join "", map
49 $_->fullstring($taglist, $d > 0 ? $d-1 : $d),
50 52 ▶ @{ $self->{TEXT} };
Branch: 1 branch
BranchTrueFalseTotal
$d > 0 ? : 8 56 64
51 $str .= "</$self->{TAG}>" if
52 52 ▶ $self->{CLOSED} and $d and not exists $taghash->{$self->{TAG}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CLOSED"} and $d and not exists $$taghash{$self->{"TAG"}} 38 14 52
Condition100%6/6
$self->{"CLOSED"} and $d and not exists $$taghash{$self->{"TAG"}}
!ll&&!rl&&r
12238
$self->{"CLOSED"} and $d
!ll&&!rl&&r
5740
MC/DC100%3/3
$self->{"CLOSED"} and $d and not exists $$taghash{$self->{"TAG"}}
$self->{"CLOSED"} $d not exists $$taghash{$self->{"TAG"}}
Truth table100%4/4
A and B and not(C)
A= $self->{"CLOSED"}B= $dC= not exists $$taghash{$self->{"TAG"}}
ABCresult
0XX0
10X0
1100
1111
53 52 return $str;
54 }
55  
56 0 ▶sub get_attr {
Subroutine get_attr: not called CC=3 SCAR=24.8
57 0 my $self = shift;
58 0 ▶ return %{ $self->{ATTR} } if not @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
59 0 ▶ return $self->{ATTR}{$_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
60 0 return @{ $self->{ATTR} }{map lc, @_};
61 }
62  
63 0 ▶sub has_attr {
Subroutine has_attr: not called CC=2 SCAR=17.9
64 0 my $self = shift;
65 0 ▶ return exists $self->{ATTR}{lc $_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
66 0 return map exists $self->{ATTR}{lc $_}, @_;
67 }
68  
69 0 ▶sub set_attr {
Subroutine set_attr: not called CC=2 SCAR=17.9
70 0 my $self = shift;
71 0 ▶ while (my $k = shift) { $self->{ATTR}{lc $k} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (my $k = shift()) 0 0 0
72 }
73  
74 0 ▶sub rem_attr {
Subroutine rem_attr: not called CC=1 SCAR=6.9
75 0 my $self = shift;
76 0 delete @{ $self->{ATTR} }{map lc, @_};
77 }
78  
79 0 ▶sub closed { $_[0]{CLOSED} }
Subroutine closed: not called CC=1 SCAR=6.9
80 0 ▶sub implied_closed { $_[0]{IMPLIED} }
Subroutine implied_closed: not called CC=1 SCAR=6.9
81 1 ▶sub tag { $_[0]{TAG} }
Subroutine tag: called CC=1 SCAR=0.0
82  
83  
84  
85 package YAPE::HTML::closetag;
86  
87 71 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
88 71 my ($class, $tag) = @_;
89 71 bless { TYPE => 'closetag', TAG => $tag }, $class;
90 }
91  
92 0 ▶sub string { "</$_[0]{TAG}>" }
Subroutine string: not called CC=1 SCAR=6.9
93 0 ▶sub tag { $_[0]{TAG} }
Subroutine tag: not called CC=1 SCAR=6.9
94  
95  
96  
97 package YAPE::HTML::text;
98  
99 136 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
100 136 my ($class, $text) = @_;
101 136 bless { TYPE => 'text', TEXT => $text }, $class;
102 }
103  
104  
105  
106 package YAPE::HTML::comment;
107  
108 18 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
109 18 my ($class, $comment) = @_;
110 18 bless { TYPE => 'comment', TEXT => $comment }, $class;
111 }
112  
113 9 ▶sub string { "<!--$_[0]{TEXT}-->" }
Subroutine string: called CC=1 SCAR=0.0
114  
115  
116  
117 package YAPE::HTML::dtd;
118  
119 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
120 1 my ($class, $attr) = @_;
121 1 my $hattr;
122  
123 1 ▶ $attr ||= [];
Condition50%1/2
$attr ||= []
l!l
01
MC/DC0%0/1
$attr ||= []
$attr
Truth table50%1/2
A
A= $attr
Aresult
11
00
124 1 @{$hattr}{@$attr} = ();
125 1 bless { TYPE => 'dtd', ATTR => $attr, HATTR => $hattr }, $class;
126 }
127  
128 0 ▶sub get_attr { @{ $_[0]{ATTR} } }
Subroutine get_attr: not called CC=1 SCAR=6.9
129 0 ▶sub set_attr { @{ $_[0]{HATTR} }{ @{ $_[0]{ATTR} } = @_[1..$#_] } = () }
Subroutine set_attr: not called CC=1 SCAR=6.9
130 1 ▶sub string { "<!DOCTYPE @{ $_[0]{ATTR} }>" }
Subroutine string: called CC=1 SCAR=0.0
131  
132  
133  
134 package YAPE::HTML::pi;
135  
136 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
137 0 my ($class, $name, $attr) = @_;
138 0 ▶ bless { TYPE => 'pi', NAME => $name, ATTR => $attr || {} }, $class;
Condition0%0/2
$attr || {}
l!l
00
MC/DC0%0/1
$attr || {}
$attr
Truth table0%0/2
A
A= $attr
Aresult
11
00
139 }
140  
141 0 ▶sub string {
Subroutine string: not called CC=3 SCAR=24.8
142 0 my $self = shift;
143 0 my $str = "<?$self->{NAME}";
144 0 for (sort keys %{ $self->{ATTR} }) {
145 0 $str .= " $_";
146 0 ▶ if (defined $self->{ATTR}{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"ATTR"}{$_}) 0 0 0
147 0 $str .= "=" . YAPE::HTML::quote($self->{ATTR}{$_});
148 }
149 }
150 0 $str .= "?>";
151 0 return $str;
152 }
153  
154 0 ▶sub get_attr {
Subroutine get_attr: not called CC=3 SCAR=24.8
155 0 my $self = shift;
156 0 ▶ return %{ $self->{ATTR} } if not @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
157 0 ▶ return $self->{ATTR}{$_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
158 0 return @{ $self->{ATTR} }{map lc, @_};
159 }
160  
161 0 ▶sub has_attr {
Subroutine has_attr: not called CC=2 SCAR=17.9
162 0 my $self = shift;
163 0 ▶ return exists $self->{ATTR}{lc $_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
164 0 return map exists $self->{ATTR}{lc $_}, @_;
165 }
166  
167 0 ▶sub set_attr {
Subroutine set_attr: not called CC=2 SCAR=17.9
168 0 my $self = shift;
169 0 ▶ while (my $k = shift) { $self->{ATTR}{lc $k} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (my $k = shift()) 0 0 0
170 }
171  
172 0 ▶sub rem_attr {
Subroutine rem_attr: not called CC=1 SCAR=6.9
173 0 my $self = shift;
174 0 delete @{ $self->{ATTR} }{map lc, @_};
175 }
176  
177 0 ▶sub name { $_[0]{NAME} }
Subroutine name: not called CC=1 SCAR=6.9
178  
179  
180  
181 package YAPE::HTML::ssi;
182  
183 3 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
184 3 my ($class, $com, $attr) = @_;
185 3 ▶ bless { TYPE => 'ssi', COM => $com, ATTR => $attr || {} }, $class;
Condition50%1/2
$attr || {}
l!l
03
MC/DC0%0/1
$attr || {}
$attr
Truth table50%1/2
A
A= $attr
Aresult
11
00
186 }
187  
188 2 ▶sub string {
Subroutine string: called CC=3 SCAR=11.0
189 2 my $self = shift;
190 2 my $str = "<!--#$self->{COM}";
191 2 for (sort keys %{ $self->{ATTR} }) {
192 2 $str .= " $_";
193 2 ▶ if (defined $self->{ATTR}{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"ATTR"}{$_}) 2 0 2
194 2 $str .= "=" . YAPE::HTML::quote($self->{ATTR}{$_});
195 }
196 }
197 2 $str .= "-->";
198 2 return $str;
199 }
200  
201 0 ▶sub get_attr {
Subroutine get_attr: not called CC=3 SCAR=24.8
202 0 my $self = shift;
203 0 ▶ return %{ $self->{ATTR} } if not @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
204 0 ▶ return $self->{ATTR}{$_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
205 0 return @{ $self->{ATTR} }{map lc, @_};
206 }
207  
208 0 ▶sub has_attr {
Subroutine has_attr: not called CC=2 SCAR=17.9
209 0 my $self = shift;
210 0 ▶ return exists $self->{ATTR}{lc $_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 0 0
211 0 return map exists $self->{ATTR}{lc $_}, @_;
212 }
213  
214 0 ▶sub set_attr {
Subroutine set_attr: not called CC=2 SCAR=17.9
215 0 my $self = shift;
216 0 ▶ while (my $k = shift) { $self->{ATTR}{lc $k} = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (my $k = shift()) 0 0 0
217 }
218  
219 0 ▶sub rem_attr {
Subroutine rem_attr: not called CC=1 SCAR=6.9
220 0 my $self = shift;
221 0 delete @{ $self->{ATTR} }{map lc, @_};
222 }
223  
224 0 ▶sub command { $_[0]{COM} }
Subroutine command: not called CC=1 SCAR=6.9
225  
226  
227  
228 1 1;
229  
230 __END__
« HTML.pm ↑ Summary