XPath/Number.pm

filter: Statementstmt 41.4% 17 / 41 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 5 / 15 Podpod 20.0% 2 / 10 totaltotal 31.5% 24 / 76 CC 6 SCAR 13.2
CC
6
Cov
33%
new
6.0
as_string
6.0
as_xml
6.0
CRAP 3.8
« XPath/Node.pm ↑ Summary XPath/NodeSet.pm »
1 package XML::XPath::Number;
2  
3 1 $VERSION = '1.26';
4  
5 1 ▶use XML::XPath::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use XML::XPath::Literal;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 use overload
10 1 '""' => \&value,
11 '0+' => \&value,
12 1 ▶ '<=>' => \&cmp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 0 ▶ my $class = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
16 0 my $number = shift;
17 0 ▶ if ($number !~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $number =~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)\s*$/) { } 0 0 0
18 0 $number = undef;
19 }
20 else {
21 0 $number =~ s/^\s*(.*)\s*$/$1/;
22 }
23 0 bless \$number, $class;
24 }
25  
26 sub as_string {
27 0 ▶ my $self = shift;
Subroutine as_string: not called CC=2 SCAR=17.9
Pod undocumented
28 0 ▶ defined $$self ? $$self : 'NaN';
Branch: 1 branch
BranchTrueFalseTotal
defined $$self ? : 0 0 0
29 }
30  
31 sub as_xml {
32 0 ▶ my $self = shift;
Subroutine as_xml: not called CC=2 SCAR=17.9
Pod undocumented
33 0 ▶ return "<Number>" . (defined($$self) ? $$self : 'NaN') . "</Number>\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $$self ? : 0 0 0
34 }
35  
36 sub value {
37 0 ▶ my $self = shift;
Subroutine value: not called CC=1 SCAR=6.9
Pod documented
38 0 $$self;
39 }
40  
41 sub cmp {
42 0 ▶ my $self = shift;
Subroutine cmp: not called CC=2 SCAR=17.9
Pod undocumented
43 0 my ($other, $swap) = @_;
44 0 ▶ if ($swap) {
Branch: 1 branch
BranchTrueFalseTotal
if ($swap) 0 0 0
45 0 return $other <=> $$self;
46 }
47 0 return $$self <=> $other;
48 }
49  
50 sub evaluate {
51 0 ▶ my $self = shift;
Subroutine evaluate: not called CC=1 SCAR=6.9
Pod undocumented
52 0 $self;
53 }
54  
55 sub to_boolean {
56 0 ▶ my $self = shift;
Subroutine to_boolean: not called CC=2 SCAR=17.9
Pod undocumented
57 0 ▶ return $$self ? XML::XPath::Boolean->True : XML::XPath::Boolean->False;
Branch: 1 branch
BranchTrueFalseTotal
$$self ? : 0 0 0
58 }
59  
60 0 ▶sub to_literal { XML::XPath::Literal->new($_[0]->as_string); }
Subroutine to_literal: not called CC=1 SCAR=6.9
Pod undocumented
61 0 ▶sub to_number { $_[0]; }
Subroutine to_number: not called CC=1 SCAR=6.9
Pod undocumented
62  
63 0 ▶sub string_value { return $_[0]->value }
Subroutine string_value: not called CC=1 SCAR=6.9
Pod undocumented
64  
65 1 1;
66 __END__
« XPath/Node.pm ↑ Summary XPath/NodeSet.pm »