lib/HTML/Object/DOM/XPathEvaluator.pm

filter: Statementstmt 61.5% 24 / 39 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 8 / 12 Podpod 100% 4 / 4 totaltotal 52.1% 36 / 69 CC 6 SCAR 23.3
CC
6
Cov
48%
evaluate
30.0
init
6.0
createExpression
2.0
CRAP 10.2
« lib/HTML/Object/DOM/TextTrack.pm ↑ Summary blib/lib/HTML/Object/XPath/Function.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/XPathEvaluator.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2022/01/01
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::DOM::XPathEvaluator;
15 BEGIN
16 {
17 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶ use HTML::Object::XPath;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 our $VERSION = 'v0.2.0';
24 };
25  
26 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 sub init
30 {
31 0 ▶ my $self = shift( @_ );
Subroutine init: not called CC=2 SCAR=17.9
Pod documented
32 0 $self->{_init_strict_use_sub} = 1;
33 0 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 0 0
34 0 $self->{_xp} = HTML::Object::XPath->new;
35 0 return( $self );
36 }
37  
38 0 ▶sub createExpression { return( shift->{_xp}->parse( @_ ) ); }
Subroutine createExpression: not called CC=1 SCAR=6.9
Pod documented
39  
40 0 ▶sub createNSResolver { return; }
Subroutine createNSResolver: not called CC=1 SCAR=6.9
Pod documented
41  
42 sub evaluate
43 {
44 0 ▶ my $self = shift( @_ );
Subroutine evaluate: not called CC=5 SCAR=34.0
Pod documented
45 0 my $expr = shift( @_ );
46 0 ▶ if( $self->_is_a( $expr => 'HTML::Object::XPath::Expr' ) )
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_is_a($expr, 'HTML::Object::XPath::Expr')) { } 0 0 0
elsif (not ref $expr or overload::Method($expr, '""')) { } 0 0 0
47 {
48 0 return( $expr->evaluate( @_ ) );
49 }
50 ▶ elsif( !ref( $expr ) || overload::Method( $expr, '""' ) )
Condition0%0/3
not ref $expr or overload::Method($expr, "\"\"")
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $expr or overload::Method($expr, "\"\"")
not ref $expr overload::Method($expr, "\"\"")
Truth table0%0/3
not(A) or B
A= not ref $exprB= overload::Method($expr, "\"\"")
ABresult
1X1
011
000
51 {
52 0 ▶ my $xpath = $self->{_xp}->parse( $expr ) || return( $self->pass_error( $self->{_xp}->error ) );
Condition0%0/2
$self->{'_xp'}->parse($expr) || (return $self->pass_error($self->{'_xp'}->error))
l!l
00
MC/DC0%0/1
$self->{'_xp'}->parse($expr) || (return $self->pass_error($self->{'_xp'}->error))
$self->{'_xp'}->parse($expr)
Truth table0%0/2
A
A= $self->{'_xp'}->parse($expr)
Aresult
11
00
53 0 return( $xpath->evaluate( @_ ) );
54 }
55 else
56 {
57 0 return( $self->error({
58 message => 'Value provided (' . overload::StrVal( $expr ) . ' is not a HTML::Object::XPath::Expr object. You can create one using createExpression()',
59 class => 'HTML::Object::TypeError',
60 }) );
61 }
62 0 return( $self );
63 }
64  
65 1 1;
66 # NOTE: POD
67 __END__
« lib/HTML/Object/DOM/TextTrack.pm ↑ Summary blib/lib/HTML/Object/XPath/Function.pm »