| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/Text.pm | ||||||||||||||||||||||||||||
| 3 | ## Version v0.2.1_1 | ||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2024 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||
| 6 | ## Created 2021/12/13 | ||||||||||||||||||||||||||||
| 7 | ## Modified 2026/03/29 | ||||||||||||||||||||||||||||
| 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::Text; | ||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||
| 16 | 36 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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' ); | |||||||||||||||||||||||||||
| 20 | 36 | ▶ | use parent qw( HTML::Object::Text HTML::Object::DOM::CharacterData ); | ||||||||||||||||||||||||||
|
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.1_1'; | |||||||||||||||||||||||||||
| 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 | 148 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 148 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 31 | 148 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||
| 32 | 148 | ▶ | $self->HTML::Object::Text::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 148 | return( $self ); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub assignedSlot { return( shift->_set_get_object_without_init( 'assignedslot', 'HTML::Object::DOM::Element::Slot', @_ ) ); } | ||||||||||||||||||||||||||
|
Subroutine
assignedSlot: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub getAttributes { return( wantarray() ? () : [] ); } | ||||||||||||||||||||||||||
|
Subroutine
getAttributes: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 139 | ▶ | sub getChildNodes { return( wantarray() ? () : [] ); } | ||||||||||||||||||||||||||
|
Subroutine
getChildNodes: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub getElementById { return; } | ||||||||||||||||||||||||||
|
Subroutine
getElementById: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub getFirstChild { return; } | ||||||||||||||||||||||||||
|
Subroutine
getFirstChild: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub getLastChild { return; } | ||||||||||||||||||||||||||
|
Subroutine
getLastChild: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub getParentNode { return( shift->parent ); } | ||||||||||||||||||||||||||
|
Subroutine
getParentNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Inherited | ||||||||||||||||||||||||||||
| 51 | # sub getNextSibling; | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # Inherited | ||||||||||||||||||||||||||||
| 54 | # sub getPreviousSibling; | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub getRootNode { return( shift->parent->getRootNode ); } | ||||||||||||||||||||||||||
|
Subroutine
getRootNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub getValue { return( shift->value ); } | ||||||||||||||||||||||||||
|
Subroutine
getValue: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub is_inside | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
is_inside: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | 0 | my( $text, $node ) = @_; | |||||||||||||||||||||||||||
| 63 | 0 | return( $text->parent->is_inside( $node ) ); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub isAttributeNode { return(0); } | ||||||||||||||||||||||||||
|
Subroutine
isAttributeNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub isCommentNode { return(0); } | ||||||||||||||||||||||||||
|
Subroutine
isCommentNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 111 | ▶ | sub isElementNode { return(0); } | ||||||||||||||||||||||||||
|
Subroutine
isElementNode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub isEqualNode | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
isEqualNode: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 75 | 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.'))
MC/DC0%0/1
shift @_ || (return $self->error('No html element was provided to insert.'))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||
| 76 | 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
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return(0) if( !$self->_is_a( $e => 'HTML::Object::Text' ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | return( $self->value eq $e->value ); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub isNamespaceNode { return(0); } | ||||||||||||||||||||||||||
|
Subroutine
isNamespaceNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub isPINode { return(0); } | ||||||||||||||||||||||||||
|
Subroutine
isPINode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub isProcessingInstructionNode { return(0); } | ||||||||||||||||||||||||||
|
Subroutine
isProcessingInstructionNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub isTextNode { return(1); } | ||||||||||||||||||||||||||
|
Subroutine
isTextNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # Note: Property | ||||||||||||||||||||||||||||
| 90 | 1 | ▶ | sub nodeValue : lvalue { return( shift->_set_get_lvalue( 'value', @_ ) ); } | ||||||||||||||||||||||||||
|
Subroutine
nodeValue: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 413 | ▶ | sub parent { return( shift->_set_get_object_without_init({ | ||||||||||||||||||||||||||
|
Subroutine
parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 413 | field => 'parent', | |||||||||||||||||||||||||||
| 94 | weaken => 1, | ||||||||||||||||||||||||||||
| 95 | }, 'HTML::Object::DOM::Node', @_ ) ); } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | sub replaceWholeText | ||||||||||||||||||||||||||||
| 98 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
replaceWholeText: called CC=6 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 100 | 1 | my $content = shift( @_ ); | |||||||||||||||||||||||||||
| 101 | 1 | ▶ | return( $self->error({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $content and not overload::Method($content, "\"\"")
MC/DC0%0/2
ref $content and not overload::Method($content, "\"\"")
ref $content
not overload::Method($content, "\"\"")
Truth table33%1/3
A and not(B)
A= ref $contentB= not overload::Method($content, "\"\"")
| |||||||||||||||||||||||||||||
| 102 | message => "Content provided is a reference that cannot be stringified.", | ||||||||||||||||||||||||||||
| 103 | class => 'HTML::Object::TypeError', | ||||||||||||||||||||||||||||
| 104 | }) ) if( ref( $content ) && !overload::Method( $content, '""' ) ); | ||||||||||||||||||||||||||||
| 105 | 1 | my $prev = $self->left; | |||||||||||||||||||||||||||
| 106 | 1 | my $next = $self->right; | |||||||||||||||||||||||||||
| 107 | 1 | my $parent = $self->parent; | |||||||||||||||||||||||||||
| 108 | 1 | ▶ | if( !$parent ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||
| 110 | 0 | $self->value( "$content" ); | |||||||||||||||||||||||||||
| 111 | 0 | return( $self ); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | 1 | my $siblings = $parent->children; | |||||||||||||||||||||||||||
| 114 | 1 | my $pos = $siblings->pos( $self ); | |||||||||||||||||||||||||||
| 115 | 1 | ▶ | return( $self->error({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | message => "I could not find this text node among its parent's children.", | ||||||||||||||||||||||||||||
| 117 | class => 'HTML::Object::HierarchyRequestError', | ||||||||||||||||||||||||||||
| 118 | }) ) if( !defined( $pos ) ); | ||||||||||||||||||||||||||||
| 119 | 1 | my $start = $pos; | |||||||||||||||||||||||||||
| 120 | $prev->reverse->foreach(sub | ||||||||||||||||||||||||||||
| 121 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 122 | 1 | ▶ | if( !$self->_is_a( $_ => 'HTML::Object::DOM::Text' ) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
MC/DC0%0/2
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
$self->_is_a($_, "HTML::Object::DOM::Text")
$self->_is_a($_, "HTML::Object::DOM::Space")
Truth table33%1/3
A or B
A= $self->_is_a($_, "HTML::Object::DOM::Text")B= $self->_is_a($_, "HTML::Object::DOM::Space")
| |||||||||||||||||||||||||||||
| 123 | !$self->_is_a( $_ => 'HTML::Object::DOM::Space' ) ) | ||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||
| 125 | 0 | return(1); | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | 1 | $start--; | |||||||||||||||||||||||||||
| 128 | 1 | }); | |||||||||||||||||||||||||||
| 129 | 1 | my $last = $pos; | |||||||||||||||||||||||||||
| 130 | $next->foreach(sub | ||||||||||||||||||||||||||||
| 131 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 132 | 1 | ▶ | if( !$self->_is_a( $_ => 'HTML::Object::DOM::Text' ) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
MC/DC0%0/2
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
$self->_is_a($_, "HTML::Object::DOM::Text")
$self->_is_a($_, "HTML::Object::DOM::Space")
Truth table33%1/3
A or B
A= $self->_is_a($_, "HTML::Object::DOM::Text")B= $self->_is_a($_, "HTML::Object::DOM::Space")
| |||||||||||||||||||||||||||||
| 133 | !$self->_is_a( $_ => 'HTML::Object::DOM::Space' ) ) | ||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||
| 135 | 0 | return(1); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 1 | $last++; | |||||||||||||||||||||||||||
| 138 | 1 | }); | |||||||||||||||||||||||||||
| 139 | 1 | my $removed = $siblings->splice( $start, ( ( $last - $start ) + 1 ), $self ); | |||||||||||||||||||||||||||
| 140 | 1 | $_->parent( undef ) for( @$removed ); | |||||||||||||||||||||||||||
| 141 | 1 | $self->parent( $parent ); | |||||||||||||||||||||||||||
| 142 | 1 | $self->value( "$content" ); | |||||||||||||||||||||||||||
| 143 | 1 | $self->reset(1); | |||||||||||||||||||||||||||
| 144 | 1 | return( $self ); | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub splitText | ||||||||||||||||||||||||||||
| 148 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
splitText: called CC=8 SCAR=23.6
Pod
documented
| |||||||||||||||||||||||||||||
| 149 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 150 | 1 | my $offset = shift( @_ ); | |||||||||||||||||||||||||||
| 151 | 1 | ▶ | return( $self->error({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | message => "Offset value provided ($offset) is not an integer.", | ||||||||||||||||||||||||||||
| 153 | class => 'HTML::Object::TypeError', | ||||||||||||||||||||||||||||
| 154 | }) ) if( !$self->_is_integer( $offset ) ); | ||||||||||||||||||||||||||||
| 155 | 1 | my $value = $self->value; | |||||||||||||||||||||||||||
| 156 | 1 | my $size = $value->length; | |||||||||||||||||||||||||||
| 157 | 1 | ▶ | return( $self->error({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | message => "Offset value provided ($offset) is higher than the size of the string (" . $value->length . ")", | ||||||||||||||||||||||||||||
| 159 | class => 'HTML::Object::IndexSizeError', | ||||||||||||||||||||||||||||
| 160 | }) ) if( $offset > $size ); | ||||||||||||||||||||||||||||
| 161 | 1 | ▶ | if( $offset < 0 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||
| 163 | 0 | $offset = ( $offset + $size ); | |||||||||||||||||||||||||||
| 164 | # For example, in the unlikely scenario where the negative offset is nth time the size of the text | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | while( $offset < 0 && abs( $offset ) > $size ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$offset < 0 and abs $offset > $size
MC/DC0%0/2
$offset < 0 and abs $offset > $size
$offset < 0
abs $offset > $size
Truth table0%0/3
A and B
A= $offset < 0B= abs $offset > $size
| |||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||
| 167 | 0 | $offset = ( $offset + $size ); | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | 1 | my $part1 = $value->substr( 0, $offset ); | |||||||||||||||||||||||||||
| 171 | 1 | my $part2 = $value->substr( $offset ); | |||||||||||||||||||||||||||
| 172 | 1 | my $new = $self->new( value => $part2 ); | |||||||||||||||||||||||||||
| 173 | 1 | my $parent = $self->parent; | |||||||||||||||||||||||||||
| 174 | 1 | ▶ | if( $parent ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||
| 176 | 1 | $new->parent( $parent ); | |||||||||||||||||||||||||||
| 177 | 1 | my $siblings = $parent->children; | |||||||||||||||||||||||||||
| 178 | 1 | my $pos = $siblings->pos( $self ); | |||||||||||||||||||||||||||
| 179 | 1 | ▶ | return( $self->error({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | message => "Unable to find our text element among our parent's children.", | ||||||||||||||||||||||||||||
| 181 | class => 'HTML::Object::HierarchyRequestError', | ||||||||||||||||||||||||||||
| 182 | }) ) if( !defined( $pos ) ); | ||||||||||||||||||||||||||||
| 183 | 1 | $siblings->splice( $pos + 1, 0, $new ); | |||||||||||||||||||||||||||
| 184 | 1 | $self->reset(1); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | 1 | $self->value( $part1 ); | |||||||||||||||||||||||||||
| 187 | 1 | return( $new ); | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 56 | ▶ | sub string_value { return( shift->value ); } | ||||||||||||||||||||||||||
|
Subroutine
string_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub toString { return( shift->value ); } | ||||||||||||||||||||||||||
|
Subroutine
toString: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 2 | ▶ | sub wholeText { return( shift->_get_adjacent_nodes->map(sub{ $_->value })->join( '' )->scalar ); } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
wholeText: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | sub _get_adjacent_nodes | ||||||||||||||||||||||||||||
| 197 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_get_adjacent_nodes: called CC=1 SCAR=1.3
| |||||||||||||||||||||||||||||
| 198 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||
| 199 | 1 | my $prev = $self->left; | |||||||||||||||||||||||||||
| 200 | 1 | my $next = $self->right; | |||||||||||||||||||||||||||
| 201 | 1 | my $res = $self->new_array( $self ); | |||||||||||||||||||||||||||
| 202 | $prev->reverse->foreach(sub | ||||||||||||||||||||||||||||
| 203 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if( !$self->_is_a( $_ => 'HTML::Object::DOM::Text' ) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
MC/DC0%0/2
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
$self->_is_a($_, "HTML::Object::DOM::Text")
$self->_is_a($_, "HTML::Object::DOM::Space")
Truth table0%0/3
A or B
A= $self->_is_a($_, "HTML::Object::DOM::Text")B= $self->_is_a($_, "HTML::Object::DOM::Space")
| |||||||||||||||||||||||||||||
| 205 | !$self->_is_a( $_ => 'HTML::Object::DOM::Space' ) ) | ||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||
| 207 | 0 | return(1); | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | 0 | $res->unshift( $_ ); | |||||||||||||||||||||||||||
| 210 | 1 | }); | |||||||||||||||||||||||||||
| 211 | $next->foreach(sub | ||||||||||||||||||||||||||||
| 212 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||
| 213 | 1 | ▶ | if( !$self->_is_a( $_ => 'HTML::Object::DOM::Text' ) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
MC/DC0%0/2
$self->_is_a($_, "HTML::Object::DOM::Text") or $self->_is_a($_, "HTML::Object::DOM::Space")
$self->_is_a($_, "HTML::Object::DOM::Text")
$self->_is_a($_, "HTML::Object::DOM::Space")
Truth table33%1/3
A or B
A= $self->_is_a($_, "HTML::Object::DOM::Text")B= $self->_is_a($_, "HTML::Object::DOM::Space")
| |||||||||||||||||||||||||||||
| 214 | !$self->_is_a( $_ => 'HTML::Object::DOM::Space' ) ) | ||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||
| 216 | 0 | return(1); | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | 1 | $res->push( $_ ); | |||||||||||||||||||||||||||
| 219 | 1 | }); | |||||||||||||||||||||||||||
| 220 | 1 | return( $res ); | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 36 | 1; | |||||||||||||||||||||||||||
| 224 | # NOTE: POD | ||||||||||||||||||||||||||||
| 225 | __END__ | ||||||||||||||||||||||||||||