DOM2/Element/Comment.pm

filter: Statementstmt 35.7% 10 / 28 Branchbran n/a Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 30.0% 3 / 10 Podpod 100% 5 / 5 totaltotal 32.7% 18 / 55 CC 5 SCAR 20.1
CC
5
Cov
28%
xmlify
20.0
text
6.0
new
2.0
CRAP 7.5
« DOM2/Element.pm ↑ Summary DOM2.pm »
1 package XML::DOM2::Element::Comment;
2  
3 =head1 NAME
4  
5 XML::DOM2::Element::Comment
6  
7 =head1 DISCRIPTION
8  
9 Comment 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 =head2 $element->new( $name, %options )
21  
22 Create a new comment element object.
23  
24 =cut
25 sub new
26 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
27 0 my ($proto, $text, %args) = @_;
28 0 $args{'text'} = $text;
29 0 my $self = $proto->SUPER::new('comment', %args);
30 0 return $self;
31 }
32  
33 =head2 $element->xmlify()
34  
35 Returns the comment as xml.
36  
37 =cut
38 sub xmlify
39 0 ▶{
Subroutine xmlify: not called CC=4 SCAR=30.0
Pod documented
40 0 my ($self, %p) = @_;
41 0 ▶ my $sep = $p{'seperator'} || "\n";
Condition0%0/2
$p{'seperator'} || "\n"
l!l
00
MC/DC0%0/1
$p{'seperator'} || "\n"
$p{'seperator'}
Truth table0%0/2
A
A= $p{'seperator'}
Aresult
11
00
42 0 ▶ my $indent = ($p{'indent'} || ' ') x ( $p{'level'} || 0 );
Condition0%0/4
$p{'indent'} || ' '
l!l
00
$p{'level'} || 0
l!l
00
MC/DC0%0/1
$p{'indent'} || ' '
$p{'indent'}
MC/DC0%0/1
$p{'level'} || 0
$p{'level'}
Truth table0%0/2
A
A= $p{'indent'}
Aresult
11
00
Truth table0%0/2
A
A= $p{'level'}
Aresult
11
00
43 0 my $text = $self->{'text'};
44 0 $text =~ s/$sep/$sep$indent/g;
45 0 return $sep.$indent.'<!--'.$text.'-->';
46 }
47  
48 =head2 $element->text()
49  
50 Return plain text (UTF-8)
51  
52 =cut
53 sub text
54 0 ▶{
Subroutine text: not called CC=2 SCAR=17.9
Pod documented
55 0 my ($self) = @_;
56 0 ▶ return $self->{'text'} || '';
Condition0%0/2
$self->{'text'} || ''
l!l
00
MC/DC0%0/1
$self->{'text'} || ''
$self->{'text'}
Truth table0%0/2
A
A= $self->{'text'}
Aresult
11
00
57 }
58  
59 =head2 $element->setComment( $text )
60  
61 Replace comment with $text
62  
63 =cut
64 sub setComment
65 0 ▶{
Subroutine setComment: not called CC=1 SCAR=6.9
Pod documented
66 0 my ($self, $text) = @_;
67 0 $self->{'text'} = $text;
68 }
69  
70 =head2 $element->appendComment( $text )
71  
72 Append to the end of existing comment text $text
73  
74 =cut
75 sub appendComment
76 0 ▶{
Subroutine appendComment: not called CC=1 SCAR=6.9
Pod documented
77 0 my ($self, $text) = @_;
78 0 $self->{'text'} .= $text;
79 }
80  
81 =head2 $element->_can_contain_elements()
82  
83 The element can not contain sub elements.
84  
85 =cut
86 0 ▶sub _can_contain_elements { 0 }
Subroutine _can_contain_elements: not called CC=1 SCAR=6.9
87  
88 =head2 $element->_can_contain_attributes()
89  
90 The element can not contain attributes
91  
92 =cut
93 0 ▶sub _can_contain_attributes { 0 }
Subroutine _can_contain_attributes: not called CC=1 SCAR=6.9
94  
95 =head1 COPYRIGHT
96  
97 Martin Owens, doctormo@cpan.org
98  
99 =head1 SEE ALSO
100  
101 L<XML::DOM2>,L<XML::DOM2::DOM::Element>
102  
103 =cut
104 4 1;
« DOM2/Element.pm ↑ Summary DOM2.pm »