Filter/Content.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 70.0% 7 / 10 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 80.0% 48 / 60 CC 9 SCAR 12.9
CC
9
Cov
87%
update
6.7
as_html
3.0
as_xml
2.0
CRAP 3.6
« Filter/EntityReference.pm ↑ Summary Filter/PictogramFallback.pm »
1 package HTML::MobileJp::Filter::Content;
2 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 6 has _current => (
5 is => 'rw',
6 isa => 'Any',
7 );
8  
9 has html => (
10 is => 'rw',
11 isa => 'Str',
12 trigger => sub {
13 10 ▶ shift->_current('html');
Subroutine __ANON__: called CC=1 SCAR=0.0
14 },
15 6 );
16  
17 has xml => (
18 is => 'rw',
19 isa => 'XML::LibXML::Document',
20 trigger => sub {
21 2 ▶ shift->_current('xml');
Subroutine __ANON__: called CC=1 SCAR=0.0
22 },
23 6 );
24  
25 6 ▶use overload '""' => 'stringfy', fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 6 *stringfy = \&as_html;
28  
29 6 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 sub update {
32 6 ▶ my ($self, $content) = @_;
Subroutine update: called CC=6 SCAR=19.0
Pod undocumented
33 6 ▶ if (ref($content) and $content->isa(__PACKAGE__)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $content and $content->isa(__PACKAGE__)) { } 0 6 6
elsif (ref $content and $content->isa('XML::LibXML::Document')) { } 1 5 6
Condition66%2/3
ref $content and $content->isa(__PACKAGE__)
!ll&&!rl&&r
510
MC/DC0%0/2
ref $content and $content->isa(__PACKAGE__)
ref $content $content->isa(__PACKAGE__)
Truth table66%2/3
A and B
A= ref $contentB= $content->isa(__PACKAGE__)
ABresult
0X0
100
111
34 0 $self->{$_} = $content->{$_} for qw( html xml );
35 ▶ } elsif (ref($content) and $content->isa('XML::LibXML::Document')) {
Condition66%2/3
ref $content and $content->isa("XML::LibXML::Document")
!ll&&!rl&&r
501
MC/DC50%1/2
ref $content and $content->isa("XML::LibXML::Document")
ref $content $content->isa("XML::LibXML::Document")
Truth table66%2/3
A and B
A= ref $contentB= $content->isa("XML::LibXML::Document")
ABresult
0X0
100
111
36 1 $self->xml($content);
37 } else {
38 5 $self->html($content);
39 }
40 }
41  
42 sub as_html {
43 12 ▶ my ($self) = @_;
Subroutine as_html: called CC=3 SCAR=11.0
Pod undocumented
44 12 ▶ if ($self->_current ne 'html') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_current ne "html") 1 11 12
45 1 ▶ $self->html( $self->xml->toString ) if $self->_current ne 'html';
Branch: 1 branch
BranchTrueFalseTotal
if $self->_current ne "html" 1 0 1
46 }
47 12 $self->html;
48 }
49  
50 sub as_xml {
51 1 ▶ my ($self) = @_;
Subroutine as_xml: called CC=2 SCAR=7.0
Pod undocumented
52 1 ▶ if ($self->_current ne 'xml') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_current ne "xml") 1 0 1
53 1 $self->xml( XML::LibXML->new->parse_string($self->html) );
54 }
55 1 $self->xml;
56 }
57  
58 6 1;
« Filter/EntityReference.pm ↑ Summary Filter/PictogramFallback.pm »