DOM2/Element/CDATA.pm

filter: Statementstmt 51.3% 19 / 37 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 37.5% 6 / 16 Podpod 100% 7 / 7 totaltotal 50.0% 32 / 64 CC 3 SCAR 11.9
CC
3
Cov
46%
xmlify
12.0
__ANON__
2.0
__ANON__
2.0
CRAP 3.3
« DOM2/DOM/NameSpace.pm ↑ Summary DOM2/Attribute.pm »
1 package XML::DOM2::Element::CDATA;
2  
3 =head1 NAME
4  
5 XML::DOM2::Element::CDATA
6  
7 =head1 DESCRIPTION
8  
9 CDATA Element object class
10  
11 =head1 METHODS
12  
13 =cut
14  
15 4 ▶use base "XML::DOM2::Element";
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 use overload
21 0 ▶ '""' => sub { shift->auto_string( @_ ) },
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 ▶ 'eq' => sub { shift->auto_eq( @_ ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 ▶ 'ne' => sub { not shift->auto_eq( @_ ) };
Subroutine __ANON__: not called CC=1 SCAR=0.2
24  
25 =head2 $class->new( $text, %arguments )
26  
27 Create a new cdata object.
28  
29 =cut
30 sub new
31 12 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
32 12 my ($proto, $text, %args) = @_;
33 12 $args{'text'} = $text;
34 12 my $self = $proto->SUPER::new('cdata', %args);
35 12 return $self;
36 }
37  
38 =head2 $element->xmlify()
39  
40 Returns the text as a serialised xml string (serialisation)
41  
42 =cut
43 sub xmlify
44 0 ▶{
Subroutine xmlify: not called CC=3 SCAR=24.8
Pod documented
45 0 my ($self, %p) = @_;
46 0 my $sep = $p{'seperator'};
47 0 my $text = $self->text();
48 0 ▶ if($self->{'notag'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'notag'}) { } 0 0 0
elsif ($self->{'noescape'}) { } 0 0 0
49 0 return $sep.'<![CDATA['.$text.']]>'.$sep;
50 } elsif($self->{'noescape'}) {
51 0 return $text;
52 }
53 0 return $text;
54 }
55  
56 =head2 $element->text()
57  
58 Return plain text (UTF-8)
59  
60 =cut
61 sub text
62 7 ▶{
Subroutine text: called CC=1 SCAR=0.0
Pod documented
63 7 my ($self) = @_;
64 7 return $self->{'text'};
65 }
66  
67 =head2 $element->setData( $text )
68  
69 Replace text data with $text.
70  
71 =cut
72 sub setData
73 0 ▶{
Subroutine setData: not called CC=1 SCAR=6.9
Pod documented
74 0 my ($self, $text) = @_;
75 0 $self->{'text'} = $text;
76 }
77  
78 =head2 $element->appendData( $text )
79  
80 Append to the end of the data $text.
81  
82 =cut
83 sub appendData
84 0 ▶{
Subroutine appendData: not called CC=1 SCAR=6.9
Pod documented
85 0 my ($self, $text) = @_;
86 0 $self->{'text'} .= $text;
87 }
88  
89 =head2 $element->_can_contain_elements()
90  
91 The element can not contain sub elements.
92  
93 =cut
94 0 ▶sub _can_contain_elements { 0 }
Subroutine _can_contain_elements: not called CC=1 SCAR=6.9
95  
96 =head2 $element->_can_contain_attributes()
97  
98 The element can not contain attributes
99  
100 =cut
101 0 ▶sub _can_contain_attributes { 0 }
Subroutine _can_contain_attributes: not called CC=1 SCAR=6.9
102  
103 =head1 OVERLOADED
104  
105 =head2 $object->auto_string()
106  
107 =cut
108 0 ▶sub auto_string { return shift->text() }
Subroutine auto_string: not called CC=1 SCAR=6.9
Pod documented
109  
110 =head2 $object->auto_eq( $string )
111  
112 =cut
113 0 ▶sub auto_eq { return shift->text() eq shift }
Subroutine auto_eq: not called CC=1 SCAR=6.9
Pod documented
114  
115 =head1 COPYRIGHT
116  
117 Martin Owens, doctormo@cpan.org
118  
119 =head1 SEE ALSO
120  
121 L<XML::DOM2>,L<XML::DOM2::DOM::Element>
122  
123 =cut
124 4 1;
« DOM2/DOM/NameSpace.pm ↑ Summary DOM2/Attribute.pm »