lib/HTML/Object/DOM/Comment.pm

filter: Statementstmt 58.3% 28 / 48 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 40.7% 11 / 27 Podpod 100% 20 / 20 totaltotal 56.4% 61 / 108 CC 7 SCAR 14.3
CC
7
Cov
50%
isEqualNode
20.0
getAttributes
6.0
getChildNodes
2.1
CRAP 4.2
« lib/HTML/Object/XPath/Number.pm ↑ Summary blib/lib/HTML/Object/DOM/XPathEvaluator.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Comment.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::Comment;
15 BEGIN
16 {
17 32 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 32 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 32 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 32 ▶ use parent qw( HTML::Object::Comment HTML::Object::DOM::CharacterData );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 32 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 32 our $VERSION = 'v0.2.0';
23 };
24  
25 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 6 ▶ my $self = shift( @_ );
Subroutine init: called CC=2 SCAR=7.0
Pod documented
31 6 $self->{_init_strict_use_sub} = 1;
32 6 ▶ $self->HTML::Object::Comment::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->HTML::Object::Comment::init(@_) or return $self->pass_error 0 6 6
33 6 return( $self );
34 }
35  
36 0 ▶sub getAttributes { return( wantarray() ? () : [] ); }
Subroutine getAttributes: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
37  
38 4 ▶sub getChildNodes { return( wantarray() ? () : [] ); }
Subroutine getChildNodes: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 0 4
39  
40 0 ▶sub getElementById { return; }
Subroutine getElementById: not called CC=1 SCAR=6.9
Pod documented
41  
42 0 ▶sub getFirstChild { return; }
Subroutine getFirstChild: not called CC=1 SCAR=6.9
Pod documented
43  
44 0 ▶sub getLastChild { return; }
Subroutine getLastChild: not called CC=1 SCAR=6.9
Pod documented
45  
46 0 ▶sub getParentNode { return( shift->parent ); }
Subroutine getParentNode: not called CC=1 SCAR=6.9
Pod documented
47  
48 0 ▶sub getRootNode { return( shift->parent->getRootNode ); }
Subroutine getRootNode: not called CC=1 SCAR=6.9
Pod documented
49  
50 0 ▶sub getValue { return( shift->value ); }
Subroutine getValue: not called CC=1 SCAR=6.9
Pod documented
51  
52 sub isEqualNode
53 {
54 0 ▶ my $self = shift( @_ );
Subroutine isEqualNode: not called CC=4 SCAR=30.0
Pod documented
55 0 ▶ my $e = shift( @_ ) || return( $self->error( "No html element was provided to insert." ) );
Condition0%0/2
shift @_ || (return $self->error('No html element was provided to insert.'))
l!l
00
MC/DC0%0/1
shift @_ || (return $self->error('No html element was provided to insert.'))
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
56 0 ▶ return( $self->error( "Element provided (", overload::StrVal( $e ), ") is not an HTML::Object::Element." ) ) if( !$self->_is_a( $e => 'HTML::Object::Element' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($e, "HTML::Object::Element") 0 0 0
57 0 ▶ return(0) if( !$self->_is_a( $e => 'HTML::Object::Comment' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($e, "HTML::Object::Comment") 0 0 0
58 0 return( $self->value eq $e->value );
59 }
60  
61 0 ▶sub isAttributeNode { return(0); }
Subroutine isAttributeNode: not called CC=1 SCAR=6.9
Pod documented
62  
63 0 ▶sub isCommentNode { return(1); }
Subroutine isCommentNode: not called CC=1 SCAR=6.9
Pod documented
64  
65 4 ▶sub isElementNode { return(0); }
Subroutine isElementNode: called CC=1 SCAR=0.0
Pod documented
66  
67 0 ▶sub isNamespaceNode { return(0); }
Subroutine isNamespaceNode: not called CC=1 SCAR=6.9
Pod documented
68  
69 0 ▶sub isPINode { return(0); }
Subroutine isPINode: not called CC=1 SCAR=6.9
Pod documented
70  
71 0 ▶sub isProcessingInstructionNode { return(0); }
Subroutine isProcessingInstructionNode: not called CC=1 SCAR=6.9
Pod documented
72  
73 0 ▶sub isTextNode { return(0); }
Subroutine isTextNode: not called CC=1 SCAR=6.9
Pod documented
74  
75 # Note: Property
76 2 ▶sub nodeValue : lvalue { return( shift->_set_get_lvalue( 'value', @_ ) ); }
Subroutine nodeValue: called CC=1 SCAR=0.0
Pod documented
77  
78 0 ▶sub string_value { return( shift->value ); }
Subroutine string_value: not called CC=1 SCAR=6.9
Pod documented
79  
80 0 ▶sub toString { return( shift->value ); }
Subroutine toString: not called CC=1 SCAR=6.9
Pod documented
81  
82 32 1;
83 # NOTE: POD
84 __END__
85  
86 =encoding utf-8
87  
88 =head1 NAME
89  
90 HTML::Object::DOM::Comment - HTML Object DOM Comment Class
91  
92 =head1 SYNOPSIS
93  
94 use HTML::Object::DOM::Comment;
95 my $this = HTML::Object::DOM::Comment->new( value => $some_comment ) ||
96 die( HTML::Object::DOM::Comment->error, "\n" );
97  
98 =head1 VERSION
99  
100 v0.2.0
101  
102 =head1 DESCRIPTION
103  
104 The L<Comment|HTML::Object::DOM::Comment> interface represents textual notations within markup; although it is generally not visually shown, such comments are available to be read in the source view.
105  
106 Comments are represented in HTML and XML as content between '<!--' and '-->'. In XML, like inside SVG or MathML markup, the character sequence '--' cannot be used within a comment.
107  
108 It inherits from L<HTML::Object::Comment> and L<HTML::Object::DOM::CharacterData>
109  
110 =head1 INHERITANCE
111  
112 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------------+ +----------------------------+
113 | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::CharacterData | --> | HTML::Object::DOM::Comment |
114 +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------------+ +----------------------------+
115 | ^
116 | |
117 v |
118 +-----------------------+ |
119 | HTML::Object::Comment | -----------------------------------------------------------------------------------------------------------------+
120 +-----------------------+
121  
122 =head1 PROPERTIES
123  
124 =head2 nodeValue
125  
126 Sets or gets the text value for this element.
127  
128 =head1 METHODS
129  
130 =head2 getAttributes
131  
132 Returns an empty list in list context, or an empty array reference in scalar context.
133  
134 =head2 getChildNodes
135  
136 Returns an empty list in list context, or an empty array reference in scalar context.
137  
138 =head2 getElementById
139  
140 Returns an empty list in list context, or C<undef> in scalar context.
141  
142 =head2 getFirstChild
143  
144 Returns an empty list in list context, or C<undef> in scalar context.
145  
146 =head2 getLastChild
147  
148 Returns an empty list in list context, or C<undef> in scalar context.
149  
150 =head2 getParentNode
151  
152 Returns the parent node, if any.
153  
154 =head2 getRootNode
155  
156 Returns the L<root node|HTML::Object::DOM::Document>
157  
158 =head2 getValue
159  
160 Returns the text value of this comment, i.e. the text between C<<!--> and C<-->>
161  
162 =head2 isAttributeNode
163  
164 Returns false.
165  
166 =head2 isCommentNode
167  
168 Returns true.
169  
170 =head2 isElementNode
171  
172 Returns false.
173  
174 =head2 isEqualNode
175  
176 Provided with another element object, and this returns true if both comment element are the same, or false otherwise.
177  
178 =head2 isNamespaceNode
179  
180 Returns false.
181  
182 =head2 isPINode
183  
184 Returns false.
185  
186 =head2 isProcessingInstructionNode
187  
188 Returns false.
189  
190 =head2 isTextNode
191  
192 Returns false.
193  
194 =head2 string_value
195  
196 Returns the content of the comment as a string.
197  
198 =head2 toString
199  
200 Returns the content of the comment as a string.
201  
202 =head1 AUTHOR
203  
204 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
205  
206 =head1 SEE ALSO
207  
208 L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/Comment>
209  
210 =head1 COPYRIGHT & LICENSE
211  
212 Copyright(c) 2021 DEGUEST Pte. Ltd.
213  
214 All rights reserved
215  
216 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
217  
218 =cut
« lib/HTML/Object/XPath/Number.pm ↑ Summary blib/lib/HTML/Object/DOM/XPathEvaluator.pm »