lib/HTML/Object/DOM/Declaration.pm

filter: Statementstmt 44.7% 34 / 76 Branchbran 16.6% 3 / 18 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 63.1% 12 / 19 Podpod 100% 11 / 11 totaltotal 43.1% 60 / 139 CC 17 SCAR 25.1
CC
17
Cov
36%
after
30.0
before
30.0
replaceWith
20.0
CRAP 12.3
« lib/HTML/Object/Attribute.pm ↑ Summary blib/lib/HTML/Object/DOM/Implementation.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Declaration.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/13
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::DOM::Declaration;
15 BEGIN
16 {
17 35 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 35 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 35 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 35 ▶ use parent qw( HTML::Object::Declaration HTML::Object::DOM::Node );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 35 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 35 our $VERSION = 'v0.2.0';
23 };
24  
25 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 28 ▶ my $self = shift( @_ );
Subroutine init: called CC=2 SCAR=7.0
Pod documented
31 28 $self->{name} = 'html';
32 28 $self->{_init_strict_use_sub} = 1;
33 28 ▶ $self->HTML::Object::Declaration::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->HTML::Object::Declaration::init(@_) or return $self->pass_error 0 28 28
34 28 return( $self );
35 }
36  
37 sub after
38 {
39 0 ▶ my $self = shift( @_ );
Subroutine after: not called CC=5 SCAR=34.0
Pod documented
40 0 ▶ my $parent = $self->parent ||
Condition0%0/2
$self->parent || (return $self->error('No parent document is set for this DTD'))
l!l
00
MC/DC0%0/1
$self->parent || (return $self->error('No parent document is set for this DTD'))
$self->parent
Truth table0%0/2
A
A= $self->parent
Aresult
11
00
41 return( $self->error( "No parent document is set for this DTD" ) );
42 0 ▶ return if( !$parent );
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 0 0 0
43 0 my $nodes = $self->_list_to_nodes( @_ );
44 0 ▶ return if( $nodes->is_empty );
Branch: 1 branch
BranchTrueFalseTotal
if $nodes->is_empty 0 0 0
45 0 my $refNode = $self;
46 0 foreach my $node ( @$nodes )
47 {
48 0 $parent->insertAfter( $node, $refNode );
49 0 $refNode = $node;
50 }
51 0 return( $self );
52 }
53  
54 sub before
55 {
56 0 ▶ my $self = shift( @_ );
Subroutine before: not called CC=5 SCAR=34.0
Pod documented
57 0 ▶ my $parent = $self->parent ||
Condition0%0/2
$self->parent || (return $self->error('No parent document is set for this DTD'))
l!l
00
MC/DC0%0/1
$self->parent || (return $self->error('No parent document is set for this DTD'))
$self->parent
Truth table0%0/2
A
A= $self->parent
Aresult
11
00
58 return( $self->error( "No parent document is set for this DTD" ) );
59 0 ▶ return if( !$parent );
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 0 0 0
60 0 my $nodes = $self->_list_to_nodes( @_ );
61 0 ▶ return if( $nodes->is_empty );
Branch: 1 branch
BranchTrueFalseTotal
if $nodes->is_empty 0 0 0
62 0 my $refNode = $self;
63 0 foreach my $node ( @$nodes )
64 {
65 0 $parent->insertBefore( $node, $refNode );
66 0 $refNode = $node;
67 }
68 0 return( $self );
69 }
70  
71 # Note: property internalSubset read-only
72 0 ▶sub internalSubset { return( shift->new_scalar ); }
Subroutine internalSubset: not called CC=1 SCAR=6.9
Pod documented
73  
74 # Note: property name read-only
75 1 ▶sub name : lvalue { return( shift->_set_get_scalar_as_object( 'name', @_ ) ); }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
76  
77 # Note: property notations read-only
78 0 ▶sub notations { return; }
Subroutine notations: not called CC=1 SCAR=6.9
Pod documented
79  
80 # Note: property publicId read-only
81 sub publicId
82 {
83 1 ▶ my $self = shift( @_ );
Subroutine publicId: called CC=2 SCAR=7.6
Pod documented
84 1 ▶ if( my $rv = $self->original->match( qr/PUBLIC[[:blank:]\h]+\"([^\"]+)\"/ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $rv = $self->original->match(qr/PUBLIC[[:blank:]\h]+\"([^\"]+)\"/)) 0 1 1
85 {
86 0 return( $rv->capture->first );
87 }
88 1 return( '' );
89 }
90  
91 sub remove
92 {
93 0 ▶ my $self = shift( @_ );
Subroutine remove: not called CC=2 SCAR=17.9
Pod documented
94 0 ▶ my $parent = $self->parent || return;
Condition0%0/2
$self->parent || (return)
l!l
00
MC/DC0%0/1
$self->parent || (return)
$self->parent
Truth table0%0/2
A
A= $self->parent
Aresult
11
00
95 0 $parent->removeChild( $self );
96 0 return( $self );
97 }
98  
99 sub replaceWith
100 {
101 0 ▶ my $self = shift( @_ );
Subroutine replaceWith: not called CC=4 SCAR=30.0
Pod documented
102 0 ▶ my $parent = $self->parent || return;
Condition0%0/2
$self->parent || (return)
l!l
00
MC/DC0%0/1
$self->parent || (return)
$self->parent
Truth table0%0/2
A
A= $self->parent
Aresult
11
00
103 0 ▶ my $list = $self->_list_to_nodes( @_ ) || return( $self->pass_error );
Condition0%0/2
$self->_list_to_nodes(@_) || (return $self->pass_error)
l!l
00
MC/DC0%0/1
$self->_list_to_nodes(@_) || (return $self->pass_error)
$self->_list_to_nodes(@_)
Truth table0%0/2
A
A= $self->_list_to_nodes(@_)
Aresult
11
00
104 0 my $pos = $parent->nodes->pos( $self );
105 0 ▶ return( $self->error( "Unable to find our DTD object in our parent's nodes" ) ) if( !defined( $pos ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pos 0 0 0
106 0 my $dtd;
107 $list->foreach(sub
108 {
109 0 ▶ $_->parent( $parent );
Subroutine __ANON__: not called CC=2 SCAR=17.9
110 0 ▶ if( $self->_is_a( $_ => 'HTML::Object::DOM::Declaration' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_a($_, "HTML::Object::DOM::Declaration")) 0 0 0
111 {
112 0 $dtd = $_;
113 }
114 0 });
115 0 $parent->nodes->splice( $pos, 1, $list->list );
116 # Either an DTD object, if we found one, or undef
117 0 $parent->declaration( $dtd );
118 0 $parent->reset(1);
119 0 return( $self );
120 }
121  
122 16 ▶sub string_value { return; }
Subroutine string_value: called CC=1 SCAR=0.0
Pod documented
123  
124 # Note: property systemId read-only
125 sub systemId
126 {
127 1 ▶ my $self = shift( @_ );
Subroutine systemId: called CC=2 SCAR=7.6
Pod documented
128 1 ▶ if( my $rv = $self->original->match( qr/[[:blank:]\h]+\"(http[^\"]+)\"/ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $rv = $self->original->match(qr/[[:blank:]\h]+\"(http[^\"]+)\"/)) 0 1 1
129 {
130 0 return( $rv->capture->first );
131 }
132 1 return( '' );
133 }
134  
135 35 1;
136 # NOTE: POD
137 __END__
« lib/HTML/Object/Attribute.pm ↑ Summary blib/lib/HTML/Object/DOM/Implementation.pm »