Object/Text.pm

filter: Statementstmt 89.7% 35 / 39 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 100% 6 / 6 totaltotal 87.1% 54 / 62 CC 3 SCAR 3.4
CC
3
Cov
86%
as_string
2.0
init
2.0
as_xml
2.0
CRAP 1.4
« Object/DOM/Element/Anchor.pm ↑ Summary Object/Space.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/Text.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/04/22
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::Text;
15 BEGIN
16 37 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 37 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 37 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 37 warnings::register_categories( 'HTML::Object' );
20 37 ▶ use parent qw( HTML::Object::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 37 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 37 our $VERSION = 'v0.2.0';
23 };
24  
25 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 sub init
29 156 ▶{
Subroutine init: called CC=2 SCAR=7.0
Pod documented
30 156 my $self = shift( @_ );
31 156 $self->{tag} = '_text';
32 156 $self->{value} = '';
33 156 $self->{is_empty} = 1;
34 156 $self->{_init_strict_use_sub} = 1;
35 156 $self->{_exception_class} = 'HTML::Object::Exception';
36 156 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 156 0 156
37 156 return( $self );
38 }
39  
40 sub as_string
41 103 ▶{
Subroutine as_string: called CC=2 SCAR=7.1
Pod documented
42 103 my $self = shift( @_ );
43 # We need to remove the reset flag, otherwise if there are any subsequent change that need to be propagated to this text parent, HTML::Object::Element::reset will not propagate it
44 103 $self->_remove_reset;
45 103 ▶ return( $self->value->length ? $self->value : $self->original );
Branch: 1 branch
BranchTrueFalseTotal
$self->value->length ? : 103 0 103
46 }
47  
48 # There is nothing to encode because we have not touched the text in the first place.
49 # Especially in the script tag section !
50 # If the user wants to, he can and should go ahead, but it is way too dangerous for us to make assumptions
51 0 ▶sub as_xml { return( shift->as_string( @_ ) ); }
Subroutine as_xml: not called CC=1 SCAR=6.9
Pod documented
52  
53 # added to provide element-like methods to text nodes, for use by cmp
54 sub lineage
55 0 ▶{
Subroutine lineage: not called CC=1 SCAR=6.9
Pod documented
56 0 my $node = shift( @_ );
57 0 my $parent = $node->parent;
58 0 return( $parent, $parent->lineage );
59 }
60  
61 sub set_checksum
62 156 ▶{
Subroutine set_checksum: called CC=1 SCAR=0.0
Pod documented
63 156 my $self = shift( @_ );
64 156 return( $self->_get_md5_hash( $self->value->scalar ) );
65 }
66  
67 592 ▶sub value : lvalue { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
68  
69 37 1;
70 # NOTE: POD
71 __END__
« Object/DOM/Element/Anchor.pm ↑ Summary Object/Space.pm »