lib/HTML/Object/XPath/Function.pm

filter: Statementstmt 33.9% 89 / 262 Branchbran 14.5% 14 / 96 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 44.4% 20 / 45 Podpod 100% 34 / 34 totaltotal 35.5% 158 / 445 CC 57 SCAR 21.6
CC
57
Cov
29%
number
20.0
substring
20.0
translate
20.0
CRAP 8.7
« lib/HTML/Object/DOM/Element/Track.pm ↑ Summary lib/HTML/Object/TokenList.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/XPath/Function.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/05
7 ## Modified 2022/09/18
8 ## All rights reserved.
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::XPath::Function;
15 BEGIN
16 {
17 14 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 14 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 14 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 14 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 14 ▶ use vars qw( $TRUE $FALSE $BASE_CLASS $DEBUG $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 14 ▶ use HTML::Object::XPath::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 14 our $TRUE = HTML::Object::XPath::Boolean->True;
24 14 our $FALSE = HTML::Object::XPath::Boolean->False;
25 14 our $BASE_CLASS = 'HTML::Object::XPath';
26 14 our $DEBUG = 0;
27 14 our $VERSION = 'v0.2.0';
28 };
29  
30 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 sub init
34 {
35 22 ▶ my $self = shift( @_ );
Subroutine init: called CC=2 SCAR=7.0
Pod documented
36 # XPath Parser -> HTML::Object::XPath
37 22 $self->{pp} = shift( @_ );
38 22 $self->{name} = shift( @_ );
39 22 $self->{params} = shift( @_ );
40 22 $self->{_init_strict_use_sub} = 1;
41 22 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 22 22
42 22 return( $self );
43 }
44  
45 sub as_string
46 {
47 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=3 SCAR=24.8
Pod documented
48 0 my $string = $self->{name} . '(';
49 0 my $second;
50 0 foreach( @{$self->{params}} )
51 {
52 0 ▶ $string .= ',' if( $second++ );
Branch: 1 branch
BranchTrueFalseTotal
if $second++ 0 0 0
53 0 $string .= $_->as_string;
54 }
55 0 $string .= ')';
56 0 return( $string );
57 }
58  
59 sub as_xml
60 {
61 0 ▶ my $self = shift( @_ );
Subroutine as_xml: not called CC=3 SCAR=24.8
Pod documented
62 0 my $string = sprintf( '<Function name="%s"', $self->{name} );
63 0 my $params = '';
64 0 foreach( @{$self->{params}} )
65 {
66 0 $params .= '<Param>' . $_->as_xml . "</Param>\n";
67 }
68 0 ▶ if( $params )
Branch: 1 branch
BranchTrueFalseTotal
if ($params) { } 0 0 0
69 {
70 0 $string .= ">\n$params</Function>\n";
71 }
72 else
73 {
74 0 $string .= " />\n";
75 }
76 0 return( $string );
77 }
78  
79 sub boolean
80 {
81 0 ▶ my $self = shift( @_ );
Subroutine boolean: not called CC=2 SCAR=17.9
Pod documented
82 0 my( $node, @params ) = @_;
83 0 ▶ die( "boolean: Incorrect number of parameters\n" ) if( @params != 1 );
Branch: 1 branch
BranchTrueFalseTotal
if @params != 1 0 0 0
84 0 return( $params[0]->to_boolean );
85 }
86  
87 sub ceiling
88 {
89 0 ▶ my $self = shift( @_ );
Subroutine ceiling: not called CC=1 SCAR=6.9
Pod documented
90 0 my( $node, @params ) = @_;
91 0 require POSIX;
92 0 my $num = $self->number( $node, @params );
93 0 return( $self->new_number( POSIX::ceil( $num->value ) ) );
94 }
95  
96 sub concat
97 {
98 0 ▶ my $self = shift( @_ );
Subroutine concat: not called CC=2 SCAR=17.9
Pod documented
99 0 my( $node, @params ) = @_;
100 0 ▶ die( "concat: Too few parameters\n" ) if( @params < 2 );
Branch: 1 branch
BranchTrueFalseTotal
if @params < 2 0 0 0
101 # TODO: Check for improvement
102 0 my $string = join( '', map{ $_->string_value } @params );
103 0 return( $self->new_literal( $string ) );
104 }
105  
106 sub contains
107 {
108 0 ▶ my $self = shift( @_ );
Subroutine contains: not called CC=3 SCAR=24.8
Pod documented
109 0 my( $node, @params ) = @_;
110 0 ▶ die( "starts-with: incorrect number of params\n" ) unless( @params == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @params == 2 0 0 0
111 0 my $value = $params[1]->string_value;
112 0 ▶ if( $params[0]->string_value =~ /(.*?)\Q$value\E(.*)/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($params[0]->string_value =~ /(.*?)\Q$value\E(.*)/) 0 0 0
113 {
114 0 return( $TRUE );
115 }
116 0 return( $FALSE );
117 }
118  
119 sub count
120 {
121 20 ▶ my $self = shift( @_ );
Subroutine count: called CC=2 SCAR=7.0
Pod documented
122 20 my( $node, @params ) = @_;
123 20 ▶ die( "count: Parameter must be a NodeSet\n" ) unless( $params[0]->isa( 'HTML::Object::XPath::NodeSet' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $params[0]->isa("HTML::Object::XPath::NodeSet") 0 20 20
124 20 return( $self->new_number( $params[0]->size ) );
125 }
126  
127 sub evaluate
128 {
129 26 ▶ my $self = shift( @_ );
Subroutine evaluate: called CC=3 SCAR=11.0
Pod documented
130 26 my $node = shift( @_ );
131 26 ▶ while( $node->isa( 'HTML::Object::XPath::NodeSet' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("HTML::Object::XPath::NodeSet")) 6 26 32
132 {
133 6 $node = $node->get_node(1);
134 }
135 26 my @params;
136 26 foreach my $param ( @{$self->{params}} )
137 {
138 28 my $results = $param->evaluate( $node );
139 28 push( @params, $results );
140 }
141 26 return( $self->_execute( $self->{name}, $node, @params ) );
142 }
143  
144 sub false
145 {
146 0 ▶ my $self = shift( @_ );
Subroutine false: not called CC=2 SCAR=17.9
Pod documented
147 0 my( $node, @params ) = @_;
148 0 ▶ die( "true: function takes no parameters\n" ) if( @params > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if @params > 0 0 0 0
149 0 return( $FALSE );
150 }
151  
152 sub floor
153 {
154 0 ▶ my $self = shift( @_ );
Subroutine floor: not called CC=1 SCAR=6.9
Pod documented
155 0 my( $node, @params ) = @_;
156 0 require POSIX;
157 0 my $num = $self->number( $node, @params );
158 0 return( $self->new_number( POSIX::floor( $num->value ) ) );
159 }
160  
161 sub id
162 {
163 4 ▶ my $self = shift( @_ );
Subroutine id: called CC=7 SCAR=22.3
Pod documented
164 4 my( $node, @params ) = @_;
165 4 ▶ die( "id: Function takes 1 parameter\n" ) unless( @params == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @params == 1 0 4 4
166 4 my $results = $self->new_nodeset();
167 4 ▶ if( $self->_is_a( $params[0] => 'HTML::Object::XPath::NodeSet' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_a($params[0], 'HTML::Object::XPath::NodeSet')) { } 0 4 4
168 {
169 # result is the union of applying id() to the
170 # string value of each node in the nodeset.
171 0 foreach my $node ( $params[0]->get_nodelist )
172 {
173 0 my $string = $node->string_value;
174 0 $results->append( $self->id( $node, $self->new_literal( $string ) ) );
175 }
176 }
177 # The actual id() function...
178 else
179 {
180 4 my $string = $self->string( $node, $params[0] );
181 # get perl scalar
182 # $_ = $string->value;
183 # split $_
184 # my @ids = split;
185 # die( "Splitting '", $string->value, "' with result: '", join( "', '", @ids ), "'\n" );
186 4 my @ids = split( /[[:blank:]]/, $string->value );
187 4 ▶ if( $node->isAttributeNode )
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isAttributeNode) 0 4 4
188 {
189 0 warn( "calling \($node->getParentNode->getRootNode->getChildNodes)->[0] on attribute node\n" );
190 0 $node = ( $node->getParentNode->getRootNode->getChildNodes )->[0];
191 }
192 4 foreach my $id ( @ids )
193 {
194 4 ▶ if( my $found = $node->getElementById( $id ) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $found = $node->getElementById($id)) 4 0 4
195 {
196 4 $results->push( $found );
197 }
198 }
199 }
200 4 return( $results );
201 }
202  
203 sub lang
204 {
205 0 ▶ my $self = shift( @_ );
Subroutine lang: not called CC=3 SCAR=24.8
Pod documented
206 0 my( $node, @params ) = @_;
207 0 ▶ die( "lang: function takes 1 parameter\n" ) if( @params != 1 );
Branch: 1 branch
BranchTrueFalseTotal
if @params != 1 0 0 0
208 0 my $lang = $node->findvalue( '(ancestor-or-self::*[@xml:lang]/@xml:lang)[1]' );
209 0 my $lclang = lc( $params[0]->string_value );
210 # warn("Looking for lang($lclang) in $lang\n");
211 0 ▶ if( substr( lc( $lang ), 0, length( $lclang ) ) eq $lclang )
Branch: 1 branch
BranchTrueFalseTotal
if (substr(lc $lang, 0, length $lclang) eq $lclang) { } 0 0 0
212 {
213 0 return( $TRUE );
214 }
215 else
216 {
217 0 return( $FALSE );
218 }
219 }
220  
221 sub last
222 {
223 0 ▶ my $self = shift( @_ );
Subroutine last: not called CC=2 SCAR=17.9
Pod documented
224 0 my( $node, @params ) = @_;
225 0 ▶ die( "last: function doesn't take parameters\n" ) if( scalar( @params ) );
Branch: 1 branch
BranchTrueFalseTotal
if scalar @params 0 0 0
226 0 return( $self->new_number( $self->{pp}->_get_context_size ) );
227 }
228  
229 sub local_name
230 {
231 0 ▶ my $self = shift( @_ );
Subroutine local_name: not called CC=3 SCAR=24.8
Pod documented
232 0 my( $node, @params ) = @_;
233 0 ▶ if( @params > 1 )
Branch: 2 branches
BranchTrueFalseTotal
if (@params > 1) { } 0 0 0
elsif (@params) { } 0 0 0
234 {
235 0 die( "name() function takes one or no parameters\n" );
236 }
237 elsif( @params )
238 {
239 0 my $nodeset = shift( @params );
240 0 $node = $nodeset->get_node(1);
241 }
242 0 return( $self->new_literal( $node->getLocalName ) );
243 }
244  
245 sub name
246 {
247 0 ▶ my $self = shift( @_ );
Subroutine name: not called CC=3 SCAR=24.8
Pod documented
248 0 my( $node, @params ) = @_;
249 0 ▶ if( @params > 1 )
Branch: 2 branches
BranchTrueFalseTotal
if (@params > 1) { } 0 0 0
elsif (@params) { } 0 0 0
250 {
251 0 die( "name() function takes one or no parameters\n" );
252 }
253 elsif( @params )
254 {
255 0 my $nodeset = shift( @params );
256 0 $node = $nodeset->get_node(1);
257 }
258 0 return( $self->new_literal( $node->getName ) );
259 }
260  
261 sub namespace_uri
262 {
263 0 ▶ my $self = shift( @_ );
Subroutine namespace_uri: not called CC=1 SCAR=6.9
Pod documented
264 0 my( $node, @params ) = @_;
265 0 die( "namespace-uri: Function not supported\n" );
266 }
267  
268 6 ▶sub new_literal { return( shift->_class_for( 'Literal' )->new( @_ ) ); }
Subroutine new_literal: called CC=1 SCAR=0.0
Pod documented
269  
270 4 ▶sub new_nodeset { return( shift->_class_for( 'NodeSet' )->new( @_ ) ); }
Subroutine new_nodeset: called CC=1 SCAR=0.0
Pod documented
271  
272 20 ▶sub new_number { return( shift->_class_for( 'Number' )->new( @_ ) ); }
Subroutine new_number: called CC=1 SCAR=0.0
Pod documented
273  
274 sub normalize_space
275 {
276 0 ▶ my $self = shift( @_ );
Subroutine normalize_space: not called CC=3 SCAR=24.8
Pod documented
277 0 my( $node, @params ) = @_;
278 0 ▶ die( "normalize-space: Wrong number of params\n" ) if( @params > 1 );
Branch: 1 branch
BranchTrueFalseTotal
if @params > 1 0 0 0
279 0 my $str;
280 0 ▶ if( @params )
Branch: 1 branch
BranchTrueFalseTotal
if (@params) { } 0 0 0
281 {
282 0 $str = $params[0]->string_value;
283 }
284 else
285 {
286 0 $str = $node->string_value;
287 }
288 # $str =~ s/^\s*//;
289 # $str =~ s/\s*$//;
290 0 $str =~ s/^[[:blank:]\h]+|[[:blank:]\h]+$//g;
291 # $str =~ s/\s+/ /g;
292 0 $str =~ s/[[:blank:]\h]+/ /g;
293 0 return( $self->new_literal( $str ) );
294 }
295  
296 sub not
297 {
298 0 ▶ my $self = shift( @_ );
Subroutine not: not called CC=3 SCAR=24.8
Pod documented
299 0 my( $node, @params ) = @_;
300 0 ▶ $params[0] = $params[0]->to_boolean unless( $params[0]->isa( 'HTML::Object::XPath::Boolean' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $params[0]->isa("HTML::Object::XPath::Boolean") 0 0 0
301 0 ▶ return( $params[0]->value ? $FALSE : $TRUE );
Branch: 1 branch
BranchTrueFalseTotal
$params[0]->value ? : 0 0 0
302 }
303  
304 sub number
305 {
306 0 ▶ my $self = shift( @_ );
Subroutine number: not called CC=4 SCAR=30.0
Pod documented
307 0 my( $node, @params ) = @_;
308 0 ▶ die( "number: Too many parameters\n" ) if( @params > 1 );
Branch: 1 branch
BranchTrueFalseTotal
if @params > 1 0 0 0
309 0 ▶ if( @params )
Branch: 1 branch
BranchTrueFalseTotal
if (@params) 0 0 0
310 {
311 0 ▶ if( $params[0]->isa( 'HTML::Object::XPath::Node' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($params[0]->isa("HTML::Object::XPath::Node")) 0 0 0
312 {
313 0 return( $self->new_number( $params[0]->string_value ) );
314 }
315 0 return( $params[0]->to_number );
316 }
317 0 return( $self->new_number( $node->string_value ) );
318 }
319  
320 sub position
321 {
322 0 ▶ my $self = shift( @_ );
Subroutine position: not called CC=2 SCAR=17.9
Pod documented
323 0 my( $node, @params ) = @_;
324 0 ▶ if( scalar( @params ) )
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @params) 0 0 0
325 {
326 0 die( "position: function doesn't take parameters [ ", @params, " ]\n" );
327 }
328 # return pos relative to axis direction
329 0 return( $self->new_number( $self->{pp}->_get_context_pos ) );
330 }
331  
332 sub round
333 {
334 0 ▶ my $self = shift( @_ );
Subroutine round: not called CC=1 SCAR=6.9
Pod documented
335 0 my( $node, @params ) = @_;
336 0 my $num = $self->number( $node, @params );
337 0 require POSIX;
338 # Yes, I know the spec says do not do this...
339 # return( $self->new_number( POSIX::floor( $num->value + 0.5 ) ) );
340 0 return( $self->new_number( CORE::sprintf( '%.*f', $num->value ) ) );
341 }
342  
343 sub starts_with
344 {
345 0 ▶ my $self = shift( @_ );
Subroutine starts_with: not called CC=3 SCAR=24.8
Pod documented
346 0 my( $node, @params ) = @_;
347 0 ▶ die( "starts-with: incorrect number of params\n" ) unless( @params == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @params == 2 0 0 0
348 0 my( $string1, $string2 ) = ( $params[0]->string_value, $params[1]->string_value );
349 0 ▶ if( substr( $string1, 0, length( $string2 ) ) eq $string2 )
Branch: 1 branch
BranchTrueFalseTotal
if (substr($string1, 0, length $string2) eq $string2) 0 0 0
350 {
351 0 return( $TRUE );
352 }
353 0 return( $FALSE );
354 }
355  
356 sub string
357 {
358 4 ▶ my $self = shift( @_ );
Subroutine string: called CC=3 SCAR=11.8
Pod documented
359 4 my( $node, @params ) = @_;
360 4 ▶ die( "string: Too many parameters\n" ) if( @params > 1 );
Branch: 1 branch
BranchTrueFalseTotal
if @params > 1 0 4 4
361 4 ▶ if( @params )
Branch: 1 branch
BranchTrueFalseTotal
if (@params) 4 0 4
362 {
363 4 return( $self->new_literal( $params[0]->string_value ) );
364 }
365  
366 # TODO - this MUST be wrong! - not sure now. -matt
367 0 return( $self->new_literal( $node->string_value ) );
368 # default to nodeset with just $node in.
369 }
370  
371 sub string_length
372 {
373 0 ▶ my $self = shift( @_ );
Subroutine string_length: not called CC=3 SCAR=24.8
Pod documented
374 0 my( $node, @params ) = @_;
375 0 ▶ die( "string-length: Wrong number of params\n" ) if( @params > 1 );
Branch: 1 branch
BranchTrueFalseTotal
if @params > 1 0 0 0
376 0 ▶ if( @params )
Branch: 1 branch
BranchTrueFalseTotal
if (@params) { } 0 0 0
377 {
378 0 return( $self->new_number( length( $params[0]->string_value ) ) );
379 }
380 else
381 {
382 0 return( $self->new_number( length( $node->string_value ) ) );
383 }
384 }
385  
386 sub substring
387 {
388 0 ▶ my $self = shift( @_ );
Subroutine substring: not called CC=4 SCAR=30.0
Pod documented
389 0 my( $node, @params ) = @_;
390 0 ▶ die( "substring: Wrong number of parameters\n" ) if( @params < 2 || @params > 3 );
Branch: 1 branch
BranchTrueFalseTotal
if @params < 2 or @params > 3 0 0 0
Condition0%0/3
@params < 2 or @params > 3
l!l&&r!l&&!r
000
MC/DC0%0/2
@params < 2 or @params > 3
@params < 2 @params > 3
Truth table0%0/3
A or B
A= @params < 2B= @params > 3
ABresult
1X1
011
000
391 0 my( $str, $offset, $len );
392 0 $str = $params[0]->string_value;
393 0 $offset = $params[1]->value;
394 # uses 1 based offsets
395 0 $offset--;
396 0 ▶ if( @params == 3 )
Branch: 1 branch
BranchTrueFalseTotal
if (@params == 3) { } 0 0 0
397 {
398 0 $len = $params[2]->value;
399 0 return( $self->new_literal( substr( $str, $offset, $len ) ) );
400 }
401 else
402 {
403 0 return( $self->new_literal( substr( $str, $offset ) ) );
404 }
405 }
406  
407 sub substring_after
408 {
409 2 ▶ my $self = shift( @_ );
Subroutine substring_after: called CC=3 SCAR=11.4
Pod documented
410 2 my( $node, @params ) = @_;
411 2 ▶ die( "starts-with: incorrect number of params\n" ) unless( @params == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @params == 2 0 2 2
412 2 my $long = $params[0]->string_value;
413 2 my $short = $params[1]->string_value;
414 2 ▶ if( $long =~ m{\Q$short\E(.*)$} )
Branch: 1 branch
BranchTrueFalseTotal
if ($long =~ /\Q$short\E(.*)$/) { } 2 0 2
415 {
416 2 return( $self->new_literal( $1 ) );
417 }
418 else
419 {
420 0 return( $self->new_literal( '' ) );
421 }
422 }
423  
424 sub substring_before
425 {
426 0 ▶ my $self = shift( @_ );
Subroutine substring_before: not called CC=3 SCAR=24.8
Pod documented
427 0 my( $node, @params ) = @_;
428 0 ▶ die( "starts-with: incorrect number of params\n" ) unless( @params == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @params == 2 0 0 0
429 0 my $long = $params[0]->string_value;
430 0 my $short = $params[1]->string_value;
431 0 ▶ if( $long =~ m{^(.*?)\Q$short} )
Branch: 1 branch
BranchTrueFalseTotal
if ($long =~ /^(.*?)\Q$short\E/) { } 0 0 0
432 {
433 0 return( $self->new_literal( $1 ) );
434 }
435 else
436 {
437 0 return( $self->new_literal( '' ) );
438 }
439 }
440  
441 sub sum
442 {
443 0 ▶ my $self = shift( @_ );
Subroutine sum: not called CC=3 SCAR=24.8
Pod documented
444 0 my( $node, @params ) = @_;
445 0 ▶ die( "sum: Parameter must be a NodeSet\n" ) unless( $params[0]->isa( 'HTML::Object::XPath::NodeSet' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $params[0]->isa("HTML::Object::XPath::NodeSet") 0 0 0
446 0 my $sum = 0;
447 0 foreach my $node ( $params[0]->get_nodelist )
448 {
449 0 $sum += $self->number( $node )->value;
450 }
451 0 return( $self->new_number( $sum ) );
452 }
453  
454 sub translate
455 {
456 0 ▶ my $self = shift( @_ );
Subroutine translate: not called CC=4 SCAR=30.0
Pod documented
457 0 my( $node, @params ) = @_;
458 0 ▶ die( "translate: Wrong number of params\n" ) if( @params != 3 );
Branch: 1 branch
BranchTrueFalseTotal
if @params != 3 0 0 0
459 0 local $_ = $params[0]->string_value;
460 0 my $find = $params[1]->string_value;
461 0 my $repl = $params[2]->string_value;
462 0 $repl= substr( $repl, 0, length( $find ) );
463 0 my %repl;
464 0 @repl{split( //, $find )} = split( //, $repl );
465 0 s{(.)}
466 {
467 0 ▶ CORE::exists( $repl{$1} ) ? defined( $repl{$1} ) ? $repl{$1} : '' : $1
Branch: 2 branches
BranchTrueFalseTotal
exists $repl{$1} ? : 0 0 0
defined $repl{$1} ? : 0 0 0
468 }ges;
469 0 return( $self->new_literal( $_ ) );
470 }
471  
472 sub true
473 {
474 0 ▶ my $self = shift( @_ );
Subroutine true: not called CC=2 SCAR=17.9
Pod documented
475 0 my( $node, @params ) = @_;
476 0 ▶ die( "true: function takes no parameters\n" ) if( @params > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if @params > 0 0 0 0
477 0 return( $TRUE );
478 }
479  
480 sub _class_for
481 {
482 30 ▶ my( $self, $mod ) = @_;
Subroutine _class_for: called CC=3 SCAR=11.3
483 30 eval( "require ${BASE_CLASS}\::${mod};" );
484 30 ▶ die( $@ ) if( $@ );
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 30 30
485 # ${"${BASE_CLASS}\::${mod}\::DEBUG"} = $DEBUG;
486 30 ▶ eval( "\$${BASE_CLASS}\::${mod}\::DEBUG = " . ( $DEBUG // 0 ) );
Condition50%1/2
$HTML::Object::XPath::Function::DEBUG // 0
l!l
300
MC/DC0%0/1
$HTML::Object::XPath::Function::DEBUG // 0
$HTML::Object::XPath::Function::DEBUG
Truth table50%1/2
A
A= $HTML::Object::XPath::Function::DEBUG
Aresult
11
00
487 30 return( "${BASE_CLASS}::${mod}" );
488 }
489  
490 sub _execute
491 {
492 26 ▶ my $self = shift( @_ );
Subroutine _execute: called CC=2 SCAR=7.0
493 26 my( $name, $node, @params ) = @_;
494 26 ▶ return( $self->error( "No function name was provided to execute." ) ) if( !$name );
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 26 26
495 26 $name =~ s/-/_/g;
496 14 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
497 26 return( $self->$name( $node, @params ) );
498 }
499  
500 14 1;
501 # NOTE: POD
502 __END__
« lib/HTML/Object/DOM/Element/Track.pm ↑ Summary lib/HTML/Object/TokenList.pm »