Object/XPath/Number.pm

filter: Statementstmt 64.9% 37 / 57 Branchbran 6.2% 1 / 16 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 54.5% 12 / 22 Podpod 100% 13 / 13 totaltotal 55.1% 64 / 116 CC 11 SCAR 14.4
CC
11
Cov
50%
_class_for
12.0
as_string
6.0
as_xml
6.0
CRAP 4.2
« Object/DOM/Space.pm ↑ Summary Object/DOM/Comment.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/XPath/Number.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::Number;
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 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 new
34 32 ▶{
Subroutine new: called CC=3 SCAR=12.3
Pod documented
35 32 my $this = shift( @_ );
36 32 my $number = shift( @_ );
37 32 ▶ if( $number !~ /^[[:blank:]\h]*[+-]?(\d+(\.\d*)?|\.\d+)[[:blank:]\h]*$/ )
Branch: 1 branch
BranchTrueFalseTotal
if (not $number =~ /^[[:blank:]\h]*[+-]?(\d+(\.\d*)?|\.\d+)[[:blank:]\h]*$/) { } 0 32 32
38 {
39 0 $number = undef;
40 }
41 else
42 {
43 32 $number =~ s/^[[:blank:]\h]*(.*)[[:blank:]\h]*$/$1/;
44 }
45 32 ▶ return( bless( \$number => ( ref( $this ) || $this ) ) );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0320
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
46 }
47  
48 sub as_string
49 0 ▶{
Subroutine as_string: not called CC=2 SCAR=17.9
Pod documented
50 0 my $self = shift( @_ );
51 0 ▶ return( defined( $$self ) ? $$self : 'NaN' );
Branch: 1 branch
BranchTrueFalseTotal
defined $$self ? : 0 0 0
52 }
53  
54 sub as_xml
55 0 ▶{
Subroutine as_xml: not called CC=2 SCAR=17.9
Pod documented
56 0 my $self = shift( @_ );
57 0 ▶ return( "<Number>" . ( defined( $$self ) ? $$self : 'NaN' ) . "</Number>\n" );
Branch: 1 branch
BranchTrueFalseTotal
defined $$self ? : 0 0 0
58 }
59  
60 sub cmp
61 0 ▶{
Subroutine cmp: not called CC=2 SCAR=17.9
Pod documented
62 0 my $self = shift( @_ );
63 0 my( $other, $swap ) = @_;
64 0 ▶ return( $swap ? $other <=> $$self : $$self <=> $other );
Branch: 1 branch
BranchTrueFalseTotal
$swap ? : 0 0 0
65 }
66  
67 46 ▶sub evaluate { return( $_[0] ); }
Subroutine evaluate: called CC=1 SCAR=0.0
Pod documented
68  
69 0 ▶sub getAttributes { return( wantarray() ? () : [] ); }
Subroutine getAttributes: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
70  
71 0 ▶sub getChildNodes { return( wantarray() ? () : [] ); }
Subroutine getChildNodes: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
72  
73 0 ▶sub new_literal { return( shift->_class_for( 'Literal' )->new( @_ ) ); }
Subroutine new_literal: not called CC=1 SCAR=6.9
Pod documented
74  
75 0 ▶sub string_value { return $_[0]->value }
Subroutine string_value: not called CC=1 SCAR=6.9
Pod documented
76  
77 0 ▶sub to_boolean { return( ${$_[0]} ? $TRUE : $FALSE ); }
Subroutine to_boolean: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${$_[0];} ? : 0 0 0
78  
79 0 ▶sub to_literal { $_[0]->new_literal( $_[0]->as_string ); }
Subroutine to_literal: not called CC=1 SCAR=6.9
Pod documented
80  
81 16 ▶sub to_number { $_[0]; }
Subroutine to_number: called CC=1 SCAR=0.0
Pod documented
82  
83 66 ▶sub value { return( ${$_[0]} ); }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
84  
85 sub _class_for
86 0 ▶{
Subroutine _class_for: not called CC=3 SCAR=24.8
87 0 my( $self, $mod ) = @_;
88 0 eval( "require ${BASE_CLASS}\::${mod};" );
89 0 ▶ die( $@ ) if( $@ );
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
90 # ${"${BASE_CLASS}\::${mod}\::DEBUG"} = $DEBUG;
91 0 ▶ eval( "\$${BASE_CLASS}\::${mod}\::DEBUG = " . ( $DEBUG // 0 ) );
Condition0%0/2
$HTML::Object::XPath::Number::DEBUG // 0
l!l
00
MC/DC0%0/1
$HTML::Object::XPath::Number::DEBUG // 0
$HTML::Object::XPath::Number::DEBUG
Truth table0%0/2
A
A= $HTML::Object::XPath::Number::DEBUG
Aresult
11
00
92 0 return( "${BASE_CLASS}::${mod}" );
93 }
94  
95 14 1;
96 # NOTE: POD
97 __END__
« Object/DOM/Space.pm ↑ Summary Object/DOM/Comment.pm »