Object/XPath/Boolean.pm

filter: Statementstmt 72.0% 31 / 43 Branchbran 0.0% 0 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 64.7% 11 / 17 Podpod 100% 10 / 10 totaltotal 61.3% 54 / 88 CC 7 SCAR 11.1
CC
7
Cov
58%
cmp
6.0
getAttributes
6.0
getChildNodes
6.0
CRAP 3.0
« Object/DOM/Element/Canvas.pm ↑ Summary Object/DOM/Element/Image.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/XPath/Boolean.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::Boolean;
15 BEGIN
16 14 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
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' );
20 14 ▶ use vars qw( $DEBUG $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 14 ▶ use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
22 14 '""' => \&value,
23 '<=>' => \&cmp,
24 'bool' => \&value,
25 fallback => 1,
26 14 );
27 14 our $DEBUG = 0;
28 14 our $VERSION = 'v0.2.0';
29 };
30  
31 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 sub cmp
35 0 ▶{
Subroutine cmp: not called CC=2 SCAR=17.9
Pod documented
36 0 my $self = shift( @_ );
37 0 my( $other, $swap ) = @_;
38 0 ▶ if( $swap )
Branch: 1 branch
BranchTrueFalseTotal
if ($swap) 0 0 0
39 {
40 0 return( $other <=> $$self );
41 }
42 0 return( $$self <=> $other );
43 }
44  
45 sub False
46 70 ▶{
Subroutine False: called CC=2 SCAR=7.6
Pod documented
47 70 my $this = shift( @_ );
48 70 my $val = 0;
49 70 ▶ return( bless( \$val => ( ref( $this ) || $this ) ) );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0700
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
50 }
51  
52 0 ▶sub getAttributes { return( wantarray() ? () : [] ); }
Subroutine getAttributes: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
53  
54 0 ▶sub getChildNodes { return( wantarray() ? () : [] ); }
Subroutine getChildNodes: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
55  
56 0 ▶sub string_value { return( $_[0]->to_literal->value ); }
Subroutine string_value: not called CC=1 SCAR=6.9
Pod documented
57  
58 20 ▶sub to_boolean { return( $_[0] ); }
Subroutine to_boolean: called CC=1 SCAR=0.0
Pod documented
59  
60 sub to_literal
61 0 ▶{
Subroutine to_literal: not called CC=2 SCAR=17.9
Pod documented
62 0 require HTML::Object::XPath::Literal;
63 0 ▶ return( HTML::Object::XPath::Literal->new( $_[0]->value ? 'true' : 'false' ) );
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->value ? : 0 0 0
64 }
65  
66 sub to_number
67 0 ▶{
Subroutine to_number: not called CC=1 SCAR=6.9
Pod documented
68 0 require HTML::Object::XPath::Number;
69 0 return( HTML::Object::XPath::Number->new( $_[0]->value ) );
70 }
71  
72 sub True
73 70 ▶{
Subroutine True: called CC=2 SCAR=7.6
Pod documented
74 70 my $this = shift( @_ );
75 70 my $val = 1;
76 70 ▶ return( bless( \$val => ( ref( $this ) || $this ) ) );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0700
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
77 }
78  
79 sub value
80 529 ▶{
Subroutine value: called CC=1 SCAR=0.0
Pod documented
81 529 my $self = shift( @_ );
82 529 return( $$self );
83 }
84  
85 14 1;
86 # NOTE: POD
87 __END__
« Object/DOM/Element/Canvas.pm ↑ Summary Object/DOM/Element/Image.pm »