YAX/Text.pm

filter: Statementstmt 75.0% 27 / 36 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 75.0% 6 / 8 totaltotal 75.3% 49 / 65 CC 5 SCAR 5.6
CC
5
Cov
73%
as_string
3.2
data
2.1
clone
2.0
CRAP 1.8
« YAX/Builder.pm ↑ Summary YAX/Fragment.pm »
1 package YAX::Text;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use base qw/YAX::Node/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Scalar::Util qw/weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use YAX::Constants qw/TEXT_NODE/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use overload '""' => \&as_string, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub TEXT () { 0 }
13 sub PRNT () { 1 }
14  
15 51 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
16 51 my ( $class, $data ) = @_;
17 51 bless [ $data, undef ], $class;
18 }
19  
20 6 ▶sub type { TEXT_NODE }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
21 414 ▶sub name { '#text' }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
22 4 ▶sub data { $_[0][TEXT] = $_[1] if @_ == 2; $_[0][TEXT] }
Subroutine data: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 0 4 4
23  
24 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
25 0 my $self = shift;
26 0 return ref( $self )->new( $self->data );
27 }
28  
29 54 ▶sub parent { weaken( $_[0][PRNT] = $_[1] ) if @_ == 2; $_[0][PRNT] }
Subroutine parent: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 51 3 54
30  
31 4 ▶sub as_string {
Subroutine as_string: called CC=3 SCAR=11.7
Pod documented
32 4 ▶ return '' unless defined $_[0][TEXT];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0][0] 0 4 4
33 4 ▶ return '' unless length ($_[0][TEXT]);
Branch: 1 branch
BranchTrueFalseTotal
unless length $_[0][0] 0 4 4
34 4 $_[0][TEXT];
35 }
36  
37 0 ▶sub entityfy {
Subroutine entityfy: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my $text = shift;
39 0 $text =~ s/&/&/g;
40 0 $text =~ s/</&lt;/g;
41 0 $text =~ s/>/&gt;/g;
42 0 $text =~ s/'/&apos;/g;
43 0 $text =~ s/"/&quot;/g;
44 0 $text;
45 }
46  
47 3 1;
48 __END__
« YAX/Builder.pm ↑ Summary YAX/Fragment.pm »