lib/HTML/Object/Declaration.pm

filter: Statementstmt 75.0% 30 / 40 Branchbran 20.0% 2 / 10 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 76.9% 10 / 13 Podpod 100% 6 / 6 totaltotal 62.0% 49 / 79 CC 8 SCAR 17.9
CC
8
Cov
59%
as_string
20.0
name
6.0
init
4.3
CRAP 6.0
« blib/lib/HTML/Object/DOM/VideoTrackList.pm ↑ Summary lib/HTML/Object/DOM/Element/Template.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/Declaration.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/04/19
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::Declaration;
15 BEGIN
16 {
17 33 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 33 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 33 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 33 ▶ use parent qw( HTML::Object::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 33 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 33 our $VERSION = 'v0.2.0';
23 };
24  
25 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 27 ▶ my $self = shift( @_ );
Subroutine init: called CC=4 SCAR=14.6
Pod documented
31 27 $self->{is_empty} = 1;
32 27 ▶ $self->{name} = 'html' unless( CORE::exists( $self->{name} ) && CORE::length( $self->{name} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"name"} and length $self->{"name"} 0 27 27
Condition33%1/3
exists $self->{"name"} and length $self->{"name"}
!ll&&!rl&&r
0027
MC/DC0%0/2
exists $self->{"name"} and length $self->{"name"}
exists $self->{"name"} length $self->{"name"}
Truth table33%1/3
A and B
A= exists $self->{"name"}B= length $self->{"name"}
ABresult
0X0
100
111
33 27 $self->{_init_strict_use_sub} = 1;
34 27 $self->{_exception_class} = 'HTML::Object::Exception';
35 27 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 27 27
36 27 $self->{tag} = '_declaration';
37 27 return( $self );
38 }
39  
40 sub as_string
41 {
42 0 ▶ my $self = shift( @_ );
Subroutine as_string: not called CC=4 SCAR=30.0
Pod documented
43 0 ▶ if( !$self->original->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->original->is_empty) { } 0 0 0
44 {
45 0 return( $self->original );
46 }
47 else
48 {
49 0 my $name = $self->name;
50 0 ▶ return( $self->new_scalar( "<!DOCTYPE" . ( ( defined( $name ) && CORE::length( "$name" ) ) ? " ${name}" : '' ) . '>' ) );
Branch: 1 branch
BranchTrueFalseTotal
defined $name && length "$name" ? : 0 0 0
Condition0%0/3
defined $name and length "$name"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name and length "$name"
defined $name length "$name"
Truth table0%0/3
A and B
A= defined $nameB= length "$name"
ABresult
0X0
100
111
51 }
52 }
53  
54 0 ▶sub as_xml { return( shift->as_string( @_ ) ); }
Subroutine as_xml: not called CC=1 SCAR=6.9
Pod documented
55  
56 27 ▶sub checksum { return( '' ); }
Subroutine checksum: called CC=1 SCAR=0.0
Pod documented
57  
58 sub name
59 {
60 0 ▶ my $self = shift( @_ );
Subroutine name: not called CC=2 SCAR=17.9
Pod documented
61 0 ▶ if( my $rv = $self->original->match( qr/^<!DOCTYPE[[:blank:]\h]+(\w+)/ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (my $rv = $self->original->match(qr/^<!DOCTYPE[[:blank:]\h]+(\w+)/)) 0 0 0
62 {
63 0 return( lc( $rv->capture->first ) );
64 }
65 0 return( '' );
66 }
67  
68 ▶sub set_checksum {}
Subroutine set_checksum: called CC=1 SCAR=0.0
Pod documented
69  
70 33 1;
71 # NOTE: POD
72 __END__
73  
74 =encoding utf-8
75  
76 =head1 NAME
77  
78 HTML::Object::Declaration - HTML Object
79  
80 =head1 SYNOPSIS
81  
82 use HTML::Object::Declaration;
83 my $this = HTML::Object::Declaration->new || die( HTML::Object::Declaration->error, "\n" );
84  
85 =head1 VERSION
86  
87 v0.2.0
88  
89 =head1 DESCRIPTION
90  
91 This module represents a document declaration element.
92  
93 =head1 INHERITANCE
94  
95 +-----------------------+ +---------------------------+
96 | HTML::Object::Element | --> | HTML::Object::Declaration |
97 +-----------------------+ +---------------------------+
98  
99 =head1 PROPERTIES
100  
101 =head2 internalSubset
102  
103 Read-only.
104  
105 Returns an empty L<string object|Module::Generic::Scalar>
106  
107 =head2 name
108  
109 Read-only.
110  
111 A DOMString, eg C<html> for <!DOCTYPE HTML>.
112  
113 =head2 notations
114  
115 Read-only.
116  
117 A NamedNodeMap with notations declared in the DTD.
118  
119 =head2 publicId
120  
121 Read-only.
122  
123 A DOMString, eg "-//W3C//DTD HTML 4.01//EN", empty string for HTML5.
124  
125 For example, with a doctype such as:
126  
127 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
128 "http://www.w3.org/TR/html4/strict.dtd">
129  
130 or
131  
132 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
133 "http://www.w3.org/TR/html4/loose.dtd">
134  
135 =head2 systemId
136  
137 Read-only.
138  
139 A DOMString, eg "http://www.w3.org/TR/html4/strict.dtd", empty string for HTML5.
140  
141 =head1 METHODS
142  
143 =head2 after
144  
145 This method is listed here for standard compliance, but actually does nothing.
146  
147 Normally, in JavaScript, it would insert a set of Node or DOMString objects in the children list of the DocumentType's parent, just after the DocumentType object.
148  
149 =head2 as_string
150  
151 Returns a string representation of this element.
152  
153 =head2 as_xml
154  
155 Returns a xml representation of this element. This is actually an alias for L</as_string>
156  
157 =head2 before
158  
159 This method is listed here for standard compliance, but actually does nothing.
160  
161 Normally, in JavaScript, it would insert a set of Node or DOMString objects in the children list of the DocumentType's parent, just before the DocumentType object.
162  
163 =head2 checksum
164  
165 Returns an empty string.
166  
167 =head2 set_checksum
168  
169 Returns nothing.
170  
171 =head1 AUTHOR
172  
173 Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
174  
175 =head1 SEE ALSO
176  
177 L<https://html.spec.whatwg.org/multipage/syntax.html#the-doctype>
178  
179 L<https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode>
180  
181 L<https://developer.mozilla.org/en-US/docs/Web/API/DocumentType>
182  
183 L<HTML::Object>, L<HTML::Object::Attribute>, L<HTML::Object::Boolean>, L<HTML::Object::Closing>, L<HTML::Object::Collection>, L<HTML::Object::Comment>, L<HTML::Object::Declaration>, L<HTML::Object::Document>, L<HTML::Object::Element>, L<HTML::Object::Exception>, L<HTML::Object::Literal>, L<HTML::Object::Number>, L<HTML::Object::Root>, L<HTML::Object::Space>, L<HTML::Object::Text>, L<HTML::Object::XQuery>
184  
185 =head1 COPYRIGHT & LICENSE
186  
187 Copyright (c) 2021 DEGUEST Pte. Ltd.
188  
189 All rights reserved
190  
191 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
192  
193 =cut
« blib/lib/HTML/Object/DOM/VideoTrackList.pm ↑ Summary lib/HTML/Object/DOM/Element/Template.pm »