lib/HTML/Object/DOM/Collection.pm

filter: Statementstmt 84.1% 53 / 63 Branchbran 31.8% 7 / 22 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 80.9% 17 / 21 Podpod 100% 2 / 2 totaltotal 71.1% 84 / 118 CC 15 SCAR 26.7
CC
15
Cov
70%
namedItem
42.2
_can
4.2
AUTOLOAD
2.0
CRAP 14.4
« lib/HTML/Object/DOM/TreeWalker.pm ↑ Summary lib/HTML/Object/DOM/Element/Label.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Collection.pm
3 ## Version v0.3.0
4 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/24
7 ## Modified 2025/10/16
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::Collection;
15 BEGIN
16 {
17 5 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶ use parent qw( Module::Generic::Array );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶ use vars qw( $AUTOLOAD $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶ use Module::Generic::Null;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶ use Wanted;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 use overload (
26 1 ▶ 'eq' => sub{ Scalar::Util::refaddr( $_[0] ) eq Scalar::Util::refaddr( $_[1] ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
27 0 ▶ '==' => sub{ Scalar::Util::refaddr( $_[0] ) eq Scalar::Util::refaddr( $_[1] ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 1032 ▶ bool => sub{ $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
29 5 fallback => 1,
30 5 ▶ );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 5 our $AUTOLOAD;
32 5 our $VERSION = 'v0.3.0';
33 };
34  
35 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 0 ▶sub item { return( shift->index( @_ ) ); }
Subroutine item: not called CC=1 SCAR=6.9
Pod documented
39  
40 sub namedItem
41 {
42 2 ▶ my $self = shift( @_ );
Subroutine namedItem: called CC=11 SCAR=37.4
Pod documented
43 2 my $name = shift( @_ );
44 2 for( @$self )
45 {
46 4 ▶ return( $_ ) if( $self->_can( $_ => 'id' ) && $_->id eq $name );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_can($_, "id") and $_->id eq $name 2 2 4
Condition66%2/3
$self->_can($_, "id") and $_->id eq $name
!ll&&!rl&&r
022
MC/DC50%1/2
$self->_can($_, "id") and $_->id eq $name
$self->_can($_, "id") $_->id eq $name
Truth table66%2/3
A and B
A= $self->_can($_, "id")B= $_->id eq $name
ABresult
0X0
100
111
47 2 ▶ return( $_ ) if( $self->_can( $_ => 'name' ) && $_->name eq $name );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_can($_, "name") and $_->name eq $name 0 2 2
Condition66%2/3
$self->_can($_, "name") and $_->name eq $name
!ll&&!rl&&r
110
MC/DC0%0/2
$self->_can($_, "name") and $_->name eq $name
$self->_can($_, "name") $_->name eq $name
Truth table66%2/3
A and B
A= $self->_can($_, "name")B= $_->name eq $name
ABresult
0X0
100
111
48 }
49 0 ▶ if( want( 'OBJECT' ) )
Branch: 5 branches
BranchTrueFalseTotal
if (want('OBJECT')) { } 0 0 0
elsif (want('ARRAY')) { } 0 0 0
elsif (want('HASH')) { } 0 0 0
elsif (want('CODE')) { } 0 0 0
elsif (want('REFSCALAR')) { } 0 0 0
50 {
51 0 return( Module::Generic::Null->new( @_ ) );
52 }
53 elsif( want( 'ARRAY' ) )
54 {
55 0 return( [] );
56 }
57 elsif( want( 'HASH' ) )
58 {
59 0 return( {} );
60 }
61 elsif( want( 'CODE' ) )
62 {
63 0 ▶ return( sub{ return; } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 }
65 elsif( want( 'REFSCALAR' ) )
66 {
67 0 return( \undef );
68 }
69 else
70 {
71 0 return;
72 }
73 }
74  
75 sub _can
76 {
77 6 ▶ my $self = shift( @_ );
Subroutine _can: called CC=4 SCAR=14.2
78 5 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 # Nothing provided
80 6 ▶ return if( !scalar( @_ ) );
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @_ 0 6 6
81 6 ▶ return if( !defined( $_[0] ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 0 6 6
82 6 ▶ return if( !Scalar::Util::blessed( $_[0] ) );
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 6 6
83 6 return( $_[0]->can( $_[1] ) );
84 }
85  
86 # NOTE: AUTOLOAD
87 sub AUTOLOAD
88 {
89 1 ▶ my( $meth ) = our $AUTOLOAD =~ /([^:]+)$/;
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
90 1 my $self = shift( @_ );
91 1 ▶ die( "No class function \"$meth\" exists in this package \"", __PACKAGE__, "\".\n" ) if( !defined( $self ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 1 1
92 1 return( $self->namedItem( $meth ) );
93 };
94  
95 # To avoid being caught by AUTOLOAD
96 ▶sub DESTROY {};
Subroutine DESTROY: not called CC=1 SCAR=0.0
97  
98 5 1;
99 # NOTE: POD
100 __END__
« lib/HTML/Object/DOM/TreeWalker.pm ↑ Summary lib/HTML/Object/DOM/Element/Label.pm »