lib/HTML/Object/Comment.pm

filter: Statementstmt 86.0% 37 / 43 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 100% 7 / 7 totaltotal 81.4% 57 / 70 CC 4 SCAR 6.7
CC
4
Cov
80%
as_xml
6.0
as_string
2.0
init
2.0
CRAP 1.9
« lib/HTML/Object/DOM/DocumentFragment.pm ↑ Summary lib/HTML/Object/DOM/Element/Body.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/Comment.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::Comment;
15 BEGIN
16 {
17 36 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 36 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 36 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 36 ▶ use parent qw( HTML::Object::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 36 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 36 our $VERSION = 'v0.2.0';
23 };
24  
25 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 {
30 8 ▶ my $self = shift( @_ );
Subroutine init: called CC=2 SCAR=6.9
Pod documented
31 8 $self->{open_seq} = '<!--';
32 8 $self->{close_seq} = '-->';
33 8 $self->{tag} = '_comment';
34 8 $self->{value} = '';
35 8 $self->{is_empty} = 1;
36 8 $self->{_init_strict_use_sub} = 1;
37 8 $self->{_exception_class} = 'HTML::Object::Exception';
38 8 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 8 8
39 8 return( $self );
40 }
41  
42 sub as_string
43 {
44 1 ▶ my $self = shift( @_ );
Subroutine as_string: called CC=2 SCAR=7.1
Pod documented
45 # We need to remove the reset flag, otherwise if there are any subsequent change that need to be propagated to this comment parent, HTML::Object::Element::reset will not propagate it
46 1 $self->_remove_reset;
47 return(
48 1 ▶ $self->value->length
Branch: 1 branch
BranchTrueFalseTotal
$self->value->length ? : 1 0 1
49 ? $self->new_scalar( join( '', '<!--', $self->value->scalar, '-->' ) )
50 : $self->original
51 );
52 }
53  
54 sub as_xml
55 {
56 0 ▶ my $self = shift( @_ );
Subroutine as_xml: not called CC=2 SCAR=17.9
Pod documented
57 0 ▶ my $txt = $self->value->length
Branch: 1 branch
BranchTrueFalseTotal
$self->value->length ? : 0 0 0
58 ? $self->new_scalar( join( '', '<!--', $self->value->scalar, '-->' ) )
59 : $self->original;
60 # HTML::Element says there cannot be double --'s in XML comments
61 0 $txt->replace( qr/--/, '-&#45;' );
62 0 return( $txt );
63 }
64  
65 0 ▶sub close_seq { return( shift->_set_get_scalar_as_object( 'close_seq', @_ ) ); }
Subroutine close_seq: not called CC=1 SCAR=6.9
Pod documented
66  
67 0 ▶sub open_seq { return( shift->_set_get_scalar_as_object( 'open_seq', @_ ) ); }
Subroutine open_seq: not called CC=1 SCAR=6.9
Pod documented
68  
69 sub set_checksum
70 {
71 8 ▶ my $self = shift( @_ );
Subroutine set_checksum: called CC=1 SCAR=0.0
Pod documented
72 8 return( $self->_get_md5_hash( $self->value->scalar ) );
73 }
74  
75 19 ▶sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
76  
77 36 1;
78 # NOTE: POD
79 __END__
« lib/HTML/Object/DOM/DocumentFragment.pm ↑ Summary lib/HTML/Object/DOM/Element/Body.pm »