blib/lib/Tags/HTML.pm

filter: Statementstmt 78.0% 64 / 82 Branchbran 62.5% 10 / 16 Conditioncond 100% 15 / 15 MC/DCmcdc 100% 7 / 7 Subroutinesub 80.0% 16 / 20 Podpod 100% 9 / 9 totaltotal 81.2% 121 / 149 CC 14 SCAR 13.6
CC
14
Cov
79%
new
8.0
css_src
6.0
script_js
6.0
CRAP 3.9
↑ Summary
1 package Tags::HTML;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 our $VERSION = 0.10;
11  
12 # Constructor.
13 16 ▶sub new {
Subroutine new: called CC=8 SCAR=20.8
Pod documented
14 16 my ($class, @params) = @_;
15  
16 # Create object.
17 16 my $self = bless {}, $class;
18  
19 # 'CSS::Struct::Output' object.
20 16 $self->{'css'} = undef;
21  
22 # No CSS support.
23 16 $self->{'no_css'} = 0;
24  
25 # 'Tags::Output' object.
26 16 $self->{'tags'} = undef;
27  
28 # Process params.
29 16 set_params($self, @params);
30  
31 # Check to 'CSS::Struct::Output' object.
32 16 ▶ if (! $self->{'no_css'} && defined $self->{'css'}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"no_css"} and defined $self->{"css"} and not builtin::blessed($self->{"css"}) && $self->{"css"}->isa("CSS::Struct::Output")) 3 13 16
Condition100%9/9
not $self->{"no_css"} and defined $self->{"css"} and not builtin::blessed($self->{"css"}) && $self->{"css"}->isa("CSS::Struct::Output")
!ll&&!rl&&r
1213
not $self->{"no_css"} and defined $self->{"css"}
!ll&&!rl&&r
1114
builtin::blessed($self->{'css'}) && $self->{'css'}->isa('CSS::Struct::Output')
!ll&&!rl&&r
211
MC/DC100%4/4
not $self->{"no_css"} and defined $self->{"css"} and not builtin::blessed($self->{"css"}) && $self->{"css"}->isa("CSS::Struct::Output")
not $self->{"no_css"} defined $self->{"css"} builtin::blessed($self->{'css'}) $self->{'css'}->isa('CSS::Struct::Output')
Truth table100%5/5
not(A) and B and not(C && D)
A= not $self->{"no_css"}B= defined $self->{"css"}C= builtin::blessed($self->{'css'})D= $self->{'css'}->isa('CSS::Struct::Output')
ABCDresult
0XXX0
10XX0
11110
110X1
11101
33 && (! blessed($self->{'css'}) || ! $self->{'css'}->isa('CSS::Struct::Output'))) {
34  
35 3 err "Parameter 'css' must be a 'CSS::Struct::Output::*' class.";
36 }
37  
38 # Check to 'Tags' object.
39 13 ▶ if (defined $self->{'tags'}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"tags"} and not builtin::blessed($self->{"tags"}) && $self->{"tags"}->isa("Tags::Output")) 3 10 13
Condition100%6/6
defined $self->{"tags"} and not builtin::blessed($self->{"tags"}) && $self->{"tags"}->isa("Tags::Output")
!ll&&!rl&&r
823
builtin::blessed($self->{'tags'}) && $self->{'tags'}->isa('Tags::Output')
!ll&&!rl&&r
212
MC/DC100%3/3
defined $self->{"tags"} and not builtin::blessed($self->{"tags"}) && $self->{"tags"}->isa("Tags::Output")
defined $self->{"tags"} builtin::blessed($self->{'tags'}) $self->{'tags'}->isa('Tags::Output')
Truth table100%4/4
A and not(B && C)
A= defined $self->{"tags"}B= builtin::blessed($self->{'tags'})C= $self->{'tags'}->isa('Tags::Output')
ABCresult
0XX0
1110
10X1
1101
40 && (! blessed($self->{'tags'}) || ! $self->{'tags'}->isa('Tags::Output'))) {
41  
42 3 err "Parameter 'tags' must be a 'Tags::Output::*' class.";
43 }
44  
45 10 $self->{'css_src'} = [];
46 10 $self->{'script_js'} = [];
47 10 $self->{'script_js_src'} = [];
48  
49 # Object.
50 10 return $self;
51 }
52  
53 # Cleanup after dynamic part.
54 1 ▶sub cleanup {
Subroutine cleanup: called CC=1 SCAR=0.0
Pod documented
55 1 my ($self, @params) = @_;
56  
57 1 $self->_cleanup(@params);
58  
59 1 $self->{'css_src'} = [];
60 1 $self->{'script_js'} = [];
61 1 $self->{'script_js_src'} = [];
62  
63 1 return;
64 }
65  
66 # CSS link handling.
67 0 ▶sub css_src {
Subroutine css_src: not called CC=2 SCAR=17.9
Pod documented
68 0 my ($self, $css_link_ar) = @_;
69  
70 0 ▶ if (defined $css_link_ar) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $css_link_ar) 0 0 0
71 0 $self->{'css_src'} = $css_link_ar;
72 }
73  
74 0 return $self->{'css_src'};
75 }
76  
77 # Initialize in dynamic part.
78 1 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
79 1 my ($self, @params) = @_;
80  
81 1 $self->_init(@params);
82  
83 1 return;
84 }
85  
86 # Initialize in preparation phase.
87 1 ▶sub prepare {
Subroutine prepare: called CC=1 SCAR=0.0
Pod documented
88 1 my ($self, @params) = @_;
89  
90 1 $self->_prepare(@params);
91  
92 1 return;
93 }
94  
95 # Process 'Tags'.
96 3 ▶sub process {
Subroutine process: called CC=2 SCAR=6.9
Pod documented
97 3 my ($self, @params) = @_;
98  
99 3 ▶ if (! defined $self->{'tags'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"tags"}) 1 2 3
100 1 err "Parameter 'tags' isn't defined.";
101 }
102  
103 2 $self->_process(@params);
104  
105 1 return;
106 }
107  
108 # Process 'CSS::Struct'.
109 3 ▶sub process_css {
Subroutine process_css: called CC=3 SCAR=11.0
Pod documented
110 3 my ($self, @params) = @_;
111  
112 # No CSS support.
113 3 ▶ if ($self->{'no_css'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"no_css"}) 1 2 3
114 1 return;
115 }
116  
117 2 ▶ if (! defined $self->{'css'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"css"}) 1 1 2
118 1 err "Parameter 'css' isn't defined.";
119 }
120  
121 1 $self->_process_css(@params);
122  
123 0 return;
124 }
125  
126 # Javascript handling.
127 0 ▶sub script_js {
Subroutine script_js: not called CC=2 SCAR=17.9
Pod documented
128 0 my ($self, $js_code_ar) = @_;
129  
130 0 ▶ if (defined $js_code_ar) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $js_code_ar) 0 0 0
131 0 $self->{'script_js'} = $js_code_ar;
132 }
133  
134 0 return $self->{'script_js'};
135 }
136  
137 # Javascript script handling.
138 0 ▶sub script_js_src {
Subroutine script_js_src: not called CC=2 SCAR=17.9
Pod documented
139 0 my ($self, $js_link_ar) = @_;
140  
141 0 ▶ if (defined $js_link_ar) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $js_link_ar) 0 0 0
142 0 $self->{'script_js_src'} = $js_link_ar;
143 }
144  
145 0 return $self->{'script_js_src'};
146 }
147  
148 1 ▶sub _cleanup {
Subroutine _cleanup: called CC=1 SCAR=0.0
149 1 my ($self, @params) = @_;
150  
151 # Default is no special code.
152  
153 1 return;
154 }
155  
156 1 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
157 1 my ($self, @params) = @_;
158  
159 # Default is no special code.
160  
161 1 return;
162 }
163  
164 1 ▶sub _prepare {
Subroutine _prepare: called CC=1 SCAR=0.0
165 1 my ($self, @params) = @_;
166  
167 # Default is no special code.
168  
169 1 return;
170 }
171  
172 1 ▶sub _process {
Subroutine _process: called CC=1 SCAR=0.4
173 1 my ($self, @params) = @_;
174  
175 1 err "Need to be implemented in inherited class in _process() method.";
176  
177 0 return;
178 }
179  
180 1 ▶sub _process_css {
Subroutine _process_css: called CC=1 SCAR=0.4
181 1 my ($self, @params) = @_;
182  
183 1 err "Need to be implemented in inherited class in _process_css() method.";
184  
185 0 return;
186 }
187  
188 0 ▶sub _process_js {
Subroutine _process_js: not called CC=1 SCAR=6.9
189 0 my ($self, @params) = @_;
190  
191 0 err "Need to be implemented in inherited class in _process_js() method.";
192  
193 0 return;
194 }
195  
196 8 1;
197  
198 __END__
↑ Summary