| 1 | # Internal use only | ||||||||||||||||||||||||||||
| 2 | package XML::TinyXML::Selector::XPath::Context; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | our $VERSION = '0.34'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | our %Operators = ( | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | '+' => sub { $_[0] + $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | '-' => sub { $_[0] - $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | '=' => sub { ($_[0] == $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | '!=' => sub { ($_[0] != $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | '<' => sub { ($_[0] < $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | '<=' => sub { ($_[0] <= $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | '>' => sub { ($_[0] > $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | '>=' => sub { ($_[0] >= $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | '*' => sub { $_[0] * $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | 'and' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.5
| |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | if (ref($_[0]) and ref($_[0]) eq "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and ref $_[0] eq "ARRAY"
MC/DC50%1/2
ref $_[0] and ref $_[0] eq "ARRAY"
ref $_[0]
ref $_[0] eq "ARRAY"
Truth table66%2/3
A and B
A= ref $_[0]B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | return scalar(@{$_[0]})?[@{$_[0]}, @{$_[1]}]:[]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | } else { | ||||||||||||||||||||||||||||
| 23 | 2 | ▶ | return($_[0] && $_[1]) | ||||||||||||||||||||||||||
|
Condition66%2/3
$_[0] && $_[1]
MC/DC50%1/2
$_[0] && $_[1]
$_[0]
$_[1]
Truth table66%2/3
A && B
A= $_[0]B= $_[1]
| |||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | }, | ||||||||||||||||||||||||||||
| 26 | 2 | ▶ | 'or' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=22.7
| |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | if (ref($_[0]) and ref($_[0]) eq "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $_[0] and ref $_[0] eq "ARRAY"
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "ARRAY"
ref $_[0]
ref $_[0] eq "ARRAY"
Truth table33%1/3
A and B
A= ref $_[0]B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | return scalar(@{$_[0]})?$_[0]:$_[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return($_[0] || $_[1]) | ||||||||||||||||||||||||||
|
Condition0%0/3
$_[0] || $_[1]
MC/DC0%0/2
$_[0] || $_[1]
$_[0]
$_[1]
Truth table0%0/3
A || B
A= $_[0]B= $_[1]
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | 'mod' => sub { ($_[0] % $_[1]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 7 | ▶ | 'div' => sub { $_[0] | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 35 | ? $_[1] | ||||||||||||||||||||||||||||
| 36 | ? $_[0] / $_[1] | ||||||||||||||||||||||||||||
| 37 | : undef | ||||||||||||||||||||||||||||
| 38 | : $_[1] | ||||||||||||||||||||||||||||
| 39 | ? 0 | ||||||||||||||||||||||||||||
| 40 | : undef | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 4 | ); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 102 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 102 | my ($class, $xml) = @_; | |||||||||||||||||||||||||||
| 46 | 102 | my $self = { xml => $xml, | |||||||||||||||||||||||||||
| 47 | operators => \%Operators, | ||||||||||||||||||||||||||||
| 48 | items => [$xml->rootNodes] | ||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||
| 50 | 102 | return bless $self, $class; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub AUTOLOAD | ||||||||||||||||||||||||||||
| 54 | 422 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 422 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 422 | our $AUTOLOAD; | |||||||||||||||||||||||||||
| 57 | 422 | my $method = (split('::', $AUTOLOAD))[-1]; | |||||||||||||||||||||||||||
| 58 | 422 | return $self->{$method}; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 4 | 1; | |||||||||||||||||||||||||||