Object.pm

filter: Statementstmt 80.7% 155 / 192 Branchbran 38.4% 30 / 78 Conditioncond 38.4% 10 / 26 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 86.3% 38 / 44 Podpod 87.5% 21 / 24 totaltotal 67.2% 254 / 378 CC 56 SCAR 22.2
CC
56
Cov
66%
read_string
56.0
read_file
12.3
__ANON__
12.0
CRAP 9.2
« Object/Value.pm ↑ Summary Object/Element.pm »
1 ##----------------------------------------------------------------------------
2 ## CSS Object Oriented - ~/lib/CSS/Object.pm
3 ## Version v0.1.6
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2020/06/24
7 ## Modified 2023/10/11
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.
12 ##----------------------------------------------------------------------------
13 package CSS::Object;
14 BEGIN
15 {
16 6 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 6 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶ use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 6 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 6 ▶ use CSS::Object::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 6 ▶ use CSS::Object::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 6 ▶ use CSS::Object::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 6 ▶ use CSS::Object::Property;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 6 ▶ use CSS::Object::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 6 ▶ use CSS::Object::Rule::At;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 6 ▶ use CSS::Object::Rule::Keyframes;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 6 ▶ use CSS::Object::Selector;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 6 ▶ use CSS::Object::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 6 ▶ use Want ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30 6 ▶ use Devel::Confess;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 6 ▶ our $VERSION = 'v0.1.6';
Subroutine BEGIN: called CC=1 SCAR=0.0
32 };
33  
34 sub init
35 {
36 6 ▶ my $self = shift( @_ );
Subroutine init: called CC=3 SCAR=11.0
Pod documented
37 6 $self->{parser} = 'CSS::Object::Parser::Default';
38 6 $self->{format} = '';
39 6 $self->{_init_strict_use_sub} = 1;
40 6 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 6 6
41 6 ▶ unless( $self->_is_a( $self->{format}, 'CSS::Object::Format' ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_a($self->{"format"}, "CSS::Object::Format")) 3 3 6
42 {
43 3 my $format = CSS::Object::Format->new(
44 debug => $self->debug
45 );
46 3 $self->format( $format );
47 }
48 6 $self->{rules} = Module::Generic::Array->new;
49 6 return( $self );
50 }
51  
52 # Add comment at the top level. To add comment inside a rule, see add_element in CSS::Object::Rule
53 sub add_element
54 {
55 1 ▶ my $self = shift( @_ );
Subroutine add_element: called CC=3 SCAR=11.2
Pod documented
56 1 ▶ my $elem = shift( @_ ) || return( $self->error( "No element object was provided to add to this rule." ) );
Condition50%1/2
shift @_ || (return $self->error('No element object was provided to add to this rule.'))
l!l
10
MC/DC0%0/1
shift @_ || (return $self->error('No element object was provided to add to this rule.'))
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
57 1 ▶ return( $self->error( "Element object provided ($elem) is not a CSS::Object::Element object." ) ) if( !$self->_is_a( $elem, 'CSS::Object::Element' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($elem, "CSS::Object::Element") 0 1 1
58 # $elem->format( $self->format );
59 1 $elem->debug( $self->debug );
60 # $self->properties->push( $prop );
61 1 $self->elements->push( $elem );
62 1 return( $self );
63 }
64  
65 sub add_rule
66 {
67 9 ▶ my $self = shift( @_ );
Subroutine add_rule: called CC=3 SCAR=11.2
Pod documented
68 9 my $rule = shift( @_ );
69 9 ▶ return( $self->error( "No rule object was provided to add." ) ) if( !defined( $rule ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rule 0 9 9
70 9 ▶ return( $self->error( "Object provided is not a CSS::Object::Rule object." ) ) if( !$self->_is_a( $rule, 'CSS::Object::Rule' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($rule, "CSS::Object::Rule") 0 9 9
71 # $self->rules->push( $rule );
72 9 $self->elements->push( $rule );
73 9 return( $rule );
74 }
75  
76 sub as_string
77 {
78 2 ▶ my $self = shift( @_ );
Subroutine as_string: called CC=4 SCAR=19.1
Pod documented
79 2 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
80 {
81 0 my $format = shift( @_ );
82 0 ▶ return( $self->error( "Provided parameter to as_string was not an CSS::Object::Format object." ) ) if( $format !~ /^CSS\::Object\::Format/ && !$self->_is_a( $format, 'CSS::Object::Format' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $format =~ /^CSS\::Object\::Format/ or $self->_is_a($format, "CSS::Object::Format") 0 0 0
Condition0%0/3
$format =~ /^CSS\::Object\::Format/ or $self->_is_a($format, "CSS::Object::Format")
l!l&&r!l&&!r
000
MC/DC0%0/2
$format =~ /^CSS\::Object\::Format/ or $self->_is_a($format, "CSS::Object::Format")
$format =~ /^CSS\::Object\::Format/ $self->_is_a($format, "CSS::Object::Format")
Truth table0%0/3
A or B
A= $format =~ /^CSS\::Object\::Format/B= $self->_is_a($format, "CSS::Object::Format")
ABresult
1X1
011
000
83 $self->elements->foreach(sub
84 {
85 0 ▶ shift->format( $format );
Subroutine __ANON__: not called CC=1 SCAR=6.9
86 0 });
87 }
88  
89 2 my $output = Module::Generic::Array->new;
90 # $self->rules->foreach(sub
91 $self->elements->foreach(sub
92 {
93 4 ▶ $output->push( shift->as_string );
Subroutine __ANON__: called CC=1 SCAR=0.0
94 2 });
95 2 my $nl = $self->format->new_line;
96 2 return( $output->join( "$nl$nl" )->scalar );
97 }
98  
99 sub builder
100 {
101 1 ▶ my $self = shift( @_ );
Subroutine builder: called CC=3 SCAR=11.3
Pod documented
102 1 ▶ return( $self->{_builder} ) if( $self->_is_object( $self->{_builder} ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_object($self->{"_builder"}) 0 1 1
103 1 ▶ my $b = CSS::Object::Builder->new( $self, debug => $self->debug ) ||
Condition50%1/2
'CSS::Object::Builder'->new($self, 'debug', $self->debug) || (return $self->error('Could not initialise the CSS builder: ', 'CSS::Object::Builder'->error))
l!l
10
MC/DC0%0/1
'CSS::Object::Builder'->new($self, 'debug', $self->debug) || (return $self->error('Could not initialise the CSS builder: ', 'CSS::Object::Builder'->error))
'CSS::Object::Builder'->new($self, 'debug', $self->debug)
Truth table50%1/2
A
A= 'CSS::Object::Builder'->new($self, 'debug', $self->debug)
Aresult
11
00
104 return( $self->error( "Could not initialise the CSS builder: ", CSS::Object::Builder->error ) );
105 1 $self->{_builder} = $b;
106 1 return( $b );
107 }
108  
109 1 ▶sub charset { return( shift->_set_get_scalar_as_object( 'charset', @_ ) ); }
Subroutine charset: called CC=1 SCAR=0.0
Pod documented
110  
111 # Array of CSS::Object::Element objects or their sub classes
112 25 ▶sub elements { return( shift->_set_get_object_array_object( 'elements', 'CSS::Object::Element', @_ ) ); }
Subroutine elements: called CC=1 SCAR=0.0
Pod documented
113  
114 sub format
115 {
116 105 ▶ my $self = shift( @_ );
Subroutine format: called CC=8 SCAR=24.5
Pod documented
117 105 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 99 105
118 {
119 6 my $val = shift( @_ );
120 6 my $format;
121 6 ▶ if( ref( $val ) )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $val) { } 3 3 6
elsif (not ref $val and index($val, '::') != -1) { } 3 0 3
122 {
123 3 ▶ $format = $self->_set_get_object( 'format', 'CSS::Object::Format', $val ) || return( $self->pass_error );
Condition50%1/2
$self->_set_get_object('format', 'CSS::Object::Format', $val) || (return $self->pass_error)
l!l
30
MC/DC0%0/1
$self->_set_get_object('format', 'CSS::Object::Format', $val) || (return $self->pass_error)
$self->_set_get_object('format', 'CSS::Object::Format', $val)
Truth table50%1/2
A
A= $self->_set_get_object('format', 'CSS::Object::Format', $val)
Aresult
11
00
124 }
125 # Formatter as a class name
126 ▶ elsif( !ref( $val ) && CORE::index( $val, '::' ) != -1 )
Condition33%1/3
not ref $val and index($val, "::") != -1
!ll&&!rl&&r
003
MC/DC0%0/2
not ref $val and index($val, "::") != -1
not ref $val index($val, "::") != -1
Truth table33%1/3
not(A) and B
A= not ref $valB= index($val, "::") != -1
ABresult
0X0
100
111
127 {
128 3 ▶ $self->_load_class( $val ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class($val) or return $self->pass_error 0 3 3
129 3 ▶ $format = $val->new( debug => $self->debug ) || return( $self->pass_error( $val->error ) );
Condition50%1/2
$val->new('debug', $self->debug) || (return $self->pass_error($val->error))
l!l
30
MC/DC0%0/1
$val->new('debug', $self->debug) || (return $self->pass_error($val->error))
$val->new('debug', $self->debug)
Truth table50%1/2
A
A= $val->new('debug', $self->debug)
Aresult
11
00
130 3 $self->_set_get_object( 'format', 'CSS::Object::Format', $format );
131 }
132 else
133 {
134 0 return( $self->error( "Unknown format \"$val\". I do not know what to do with it." ) );
135 }
136 $self->elements->foreach(sub
137 {
138 0 ▶ return(1) if( !$self->_is_object( $_[0] ) );
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_object($_[0]) 0 0 0
139 0 ▶ shift->format( $format ) || return;
Branch: 1 branch
BranchTrueFalseTotal
(shift())->format($format) or return 0 0 0
140 6 });
141 6 return( $format );
142 }
143 99 return( $self->_set_get_object( 'format', 'CSS::Object::Format' ) );
144 }
145  
146 sub get_rule_by_selector
147 {
148 1 ▶ my( $self, $name ) = @_;
Subroutine get_rule_by_selector: called CC=9 SCAR=24.3
Pod documented
149 1 ▶ return( $self->error( "No selector was provided to find its equivalent rule object." ) ) if( !$name );
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 1 1
150 1 my $found = Module::Generic::Array->new;
151 1 foreach my $rule ( @{$self->elements} )
152 {
153 3 ▶ next if( !$rule->isa( 'CSS::Object::Rule' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $rule->isa("CSS::Object::Rule") 0 3 3
154 3 foreach my $sel ( @{$rule->selectors} )
155 {
156 5 ▶ if( $sel->name eq $name )
Branch: 1 branch
BranchTrueFalseTotal
if ($sel->name eq $name) 1 4 5
157 {
158 # return( $rule );
159 1 $found->push( $rule );
160 }
161 }
162 }
163 ## The user is calling this in a chain context, we make sure this is possible using the Module::Generic::Null class if needed
164 1 ▶ if( Want::want( 'OBJECT' ) )
Branch: 2 branches
BranchTrueFalseTotal
if (Want::want('OBJECT')) { } 0 1 1
elsif (Want::want('LIST')) { } 0 1 1
165 {
166 0 ▶ rreturn( $found->length > 0 ? $found->first : Module::Generic::Null->new );
Branch: 1 branch
BranchTrueFalseTotal
$found->length > 0 ? : 0 0 0
167 }
168 elsif( Want::want( 'LIST' ) )
169 {
170 0 rreturn( @$found );
171 }
172 else
173 {
174 1 return( $found->first );
175 }
176 }
177  
178 sub load_parser
179 {
180 5 ▶ my $self = shift( @_ );
Subroutine load_parser: called CC=3 SCAR=11.2
Pod documented
181 5 my $parser_class = $self->parser;
182 5 ▶ $self->_load_class( "$parser_class" ) || return( $self->error( "Unable to load parser class \"$parser_class\": ", $self->error ) );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("$parser_class") or return $self->error(qq[Unable to load parser class "$parser_class": ], $self->error) 0 5 5
183 5 ▶ my $parser = $parser_class->scalar->new( $self ) || return( $self->error( "Unable to instantiate parser \"$parser_class\" object: ", $parser_class->scalar->error ) );
Condition50%1/2
$parser_class->scalar->new($self) || (return $self->error(qq[Unable to instantiate parser "$parser_class" object: ], $parser_class->scalar->error))
l!l
50
MC/DC0%0/1
$parser_class->scalar->new($self) || (return $self->error(qq[Unable to instantiate parser "$parser_class" object: ], $parser_class->scalar->error))
$parser_class->scalar->new($self)
Truth table50%1/2
A
A= $parser_class->scalar->new($self)
Aresult
11
00
184 5 $parser->debug( $self->debug );
185 5 return( $parser );
186 }
187  
188 sub new_at_rule
189 {
190 0 ▶ my $self = shift( @_ );
Subroutine new_at_rule: not called CC=2 SCAR=17.9
Pod undocumented
191 0 my $o = CSS::Object::Rule::At->new( @_,
192 format => $self->format,
193 debug => $self->debug,
194 css => $self,
195 );
196 0 ▶ return( $self->error( "Cannot create a new at rule object: ", CSS::Object::Rule::At->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 0 0
197 0 return( $o );
198 }
199  
200 sub new_keyframes_rule
201 {
202 1 ▶ my $self = shift( @_ );
Subroutine new_keyframes_rule: called CC=2 SCAR=7.0
Pod undocumented
203 1 my $o = CSS::Object::Rule::Keyframes->new( @_,
204 format => $self->format,
205 debug => $self->debug,
206 css => $self,
207 );
208 1 ▶ return( $self->error( "Cannot create a new keyframes rule object: ", CSS::Object::Rule::Keyframes->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 1 1
209 1 return( $o );
210 }
211  
212 sub new_comment
213 {
214 5 ▶ my $self = shift( @_ );
Subroutine new_comment: called CC=2 SCAR=7.0
Pod documented
215 5 my $o = CSS::Object::Comment->new( @_, format => $self->format, debug => $self->debug );
216 5 ▶ return( $self->error( "Cannot create a new comment object: ", CSS::Object::Comment->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 5 5
217 5 return( $o );
218 }
219  
220 sub new_property
221 {
222 15 ▶ my $self = shift( @_ );
Subroutine new_property: called CC=2 SCAR=7.0
Pod documented
223 15 my $o = CSS::Object::Property->new( @_, format => $self->format, debug => $self->debug );
224 15 ▶ return( $self->error( "Cannot create a new property object: ", CSS::Object::Property->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 15 15
225 15 return( $o );
226 }
227  
228 sub new_rule
229 {
230 26 ▶ my $self = shift( @_ );
Subroutine new_rule: called CC=2 SCAR=7.0
Pod documented
231 26 my $o = CSS::Object::Rule->new( @_, format => $self->format, debug => $self->debug );
232 26 ▶ return( $self->error( "Cannot create a new rule object: ", CSS::Object::Rule->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 26 26
233 26 return( $o );
234 }
235  
236 sub new_selector
237 {
238 47 ▶ my $self = shift( @_ );
Subroutine new_selector: called CC=2 SCAR=7.0
Pod documented
239 47 my $o = CSS::Object::Selector->new( @_, format => $self->format, debug => $self->debug );
240 47 ▶ return( $self->error( "Cannot create a new selector object: ", CSS::Object::Selector->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 47 47
241 47 return( $o );
242 }
243  
244 sub new_value
245 {
246 0 ▶ my $self = shift( @_ );
Subroutine new_value: not called CC=2 SCAR=17.9
Pod documented
247 0 my $o = CSS::Object::Value->new( @_, format => $self->format, debug => $self->debug );
248 0 ▶ return( $self->error( "Cannot create a new value object: ", CSS::Object::Value->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 0 0
249 0 return( $o );
250 }
251  
252 sub parse_string
253 {
254 5 ▶ my $self = shift( @_ );
Subroutine parse_string: called CC=3 SCAR=11.2
Pod documented
255 5 my $string = shift( @_ );
256  
257 # remove comments
258 # $string =~ s!/\*.*?\*\/!!g;
259 5 $string =~ s|<!--||g;
260 5 $string =~ s|-->||g;
261
262 5 ▶ my $parser = $self->load_parser || return( $self->pass_error );
Condition50%1/2
$self->load_parser || (return $self->pass_error)
l!l
50
MC/DC0%0/1
$self->load_parser || (return $self->pass_error)
$self->load_parser
Truth table50%1/2
A
A= $self->load_parser
Aresult
11
00
263 5 ▶ my $elems = $parser->parse_string( $string ) || return( $self->pass_error( $parser->error ) );
Condition50%1/2
$parser->parse_string($string) || (return $self->pass_error($parser->error))
l!l
50
MC/DC0%0/1
$parser->parse_string($string) || (return $self->pass_error($parser->error))
$parser->parse_string($string)
Truth table50%1/2
A
A= $parser->parse_string($string)
Aresult
11
00
264 5 return( $elems );
265 }
266  
267 6 ▶sub parser { return( shift->_set_get_scalar_as_object( 'parser', @_ ) ); }
Subroutine parser: called CC=1 SCAR=0.0
Pod documented
268  
269 2 ▶sub purge { return( shift->elements->reset ); }
Subroutine purge: called CC=1 SCAR=0.0
Pod documented
270  
271 sub read_file
272 {
273 5 ▶ my $self = shift( @_ );
Subroutine read_file: called CC=8 SCAR=25.1
Pod documented
274 5 my $path = shift( @_ );
275  
276 5 ▶ if( ref( $path ) )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $path) { } 0 5 5
elsif ($path) { } 5 0 5
277 {
278 0 ▶ if( ref( $path ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $path eq "ARRAY") 0 0 0
279 {
280 0 $self->read_file( $_ ) for( @$path );
281 0 return( $self );
282 }
283 }
284 elsif( $path )
285 {
286 5 ▶ my $io = IO::File->new( "<$path" ) || return( $self->error( "Could not open file \"$path\": $!" ) );
Condition50%1/2
'IO::File'->new("<$path") || (return $self->error(qq[Could not open file "$path": $!]))
l!l
50
MC/DC0%0/1
'IO::File'->new("<$path") || (return $self->error(qq[Could not open file "$path": $!]))
'IO::File'->new("<$path")
Truth table50%1/2
A
A= 'IO::File'->new("<$path")
Aresult
11
00
287 5 $io->binmode( ':utf8' );
288 5 my $source = join( '', $io->getlines );
289 5 $io->close;
290 5 ▶ if( $source )
Branch: 1 branch
BranchTrueFalseTotal
if ($source) 5 0 5
291 {
292 5 ▶ my $elems = $self->parse_string( $source ) || return( $self->pass_error );
Condition50%1/2
$self->parse_string($source) || (return $self->pass_error)
l!l
50
MC/DC0%0/1
$self->parse_string($source) || (return $self->pass_error)
$self->parse_string($source)
Truth table50%1/2
A
A= $self->parse_string($source)
Aresult
11
00
293 # $self->rules->push( @$rules );
294 5 $self->elements->push( @$elems );
295 }
296 5 return( $self );
297 }
298 0 return( $self->error( "Only scalars and arrays accepted: $!" ) );
299 }
300  
301 sub read_string
302 {
303 0 ▶ my $self = shift( @_ );
Subroutine read_string: not called CC=7 SCAR=40.3
Pod documented
304 0 my $data = shift( @_ );
305  
306 0 ▶ if( ref( $data ) )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $data) { } 0 0 0
elsif (length $data) { } 0 0 0
307 {
308 0 ▶ if( ref( $data ) eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "ARRAY") 0 0 0
309 {
310 0 for( @$data )
311 {
312 0 ▶ $self->read_string( $_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->read_string($_) or return $self->pass_error 0 0 0
313 }
314 0 return( $self );
315 }
316 }
317 elsif( length( $data ) )
318 {
319 0 ▶ my $elems = $self->parse_string( $data ) || return( $self->pass_error );
Condition0%0/2
$self->parse_string($data) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->parse_string($data) || (return $self->pass_error)
$self->parse_string($data)
Truth table0%0/2
A
A= $self->parse_string($data)
Aresult
11
00
320 ## $self->rules->push( @$rules );
321 0 $self->elements->push( @$elems );
322 }
323 0 return( $self );
324 }
325  
326 sub remove_rule
327 {
328 0 ▶ my $self = shift( @_ );
Subroutine remove_rule: not called CC=3 SCAR=24.8
Pod undocumented
329 0 my $rule = shift( @_ );
330 0 ▶ return( $self->error( "No rule object was provided to remove." ) ) if( !defined( $rule ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rule 0 0 0
331 0 ▶ return( $self->error( "Object provided is not a CSS::Object::Rule object." ) ) if( !$self->_is_a( $rule, 'CSS::Object::Rule' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($rule, "CSS::Object::Rule") 0 0 0
332 0 $self->elements->remove( $rule );
333 0 return( $self );
334 }
335  
336 # sub rules { return( shift->_set_get_array_as_object( 'rules', @_ ) ); }
337 27 ▶sub rules { return( $_[0]->elements->map(sub{ $_[0]->_is_a( $_, 'CSS::Object::Rule' ) ? $_ : () }) ); }
Subroutine __ANON__: called CC=2 SCAR=7.2
Subroutine rules: called CC=1 SCAR=0.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->_is_a($_, 'CSS::Object::Rule') ? : 27 0 27
338  
339 6 1;
340  
341 # NOTE POD
342 __END__
« Object/Value.pm ↑ Summary Object/Element.pm »