InstantArticle/Slideshow.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 88.3% 38 / 43 SCAR 13.9
CC
4
Cov
89%
add_image
3.2
__ANON__
2.0
BEGIN
1.0
CRAP 4.0
« InstantArticle/Paragraph.pm ↑ Summary InstantArticle/Map.pm »
1 package Facebook::InstantArticle::Slideshow;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 extends 'Facebook::InstantArticle::BaseElement';
6  
7 1 ▶use Facebook::InstantArticle::Figure::Image;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has '_images' => (
10 isa => 'ArrayRef[Facebook::InstantArticle::Figure::Image]',
11 is => 'ro',
12 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
13 1 );
14  
15 sub add_image {
16 1 ▶ my $self = shift;
Subroutine add_image: called CC=3 SCAR=11.8
Pod undocumented
17  
18 1 ▶ if ( my $e = Facebook::InstantArticle::Figure::Image->new(@_) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = "Facebook::InstantArticle::Figure::Image"->new(@_)) 1 0 1
19 1 ▶ if ( $e->is_valid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e->is_valid) 1 0 1
20 1 return push( @{$self->_images}, $e );
21 }
22 }
23  
24 0 $self->_log->warn( 'Failed to add image to slideshow!' );
25 }
26  
27 has 'is_valid' => (
28 isa => 'Bool',
29 is => 'ro',
30 lazy => 1,
31 default => sub {
32 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=7.1
33  
34 1 ▶ return scalar( @{$self->_images} ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$self->_images;} ? : 1 0 1
35 },
36 1 );
37  
38 1 has 'as_xml_gen' => (
39 isa => 'Object',
40 is => 'ro',
41 lazy => 1,
42 builder => '_build_as_xml_gen',
43 );
44  
45 sub _build_as_xml_gen {
46 1 ▶ my $self = shift;
Subroutine _build_as_xml_gen: called CC=1 SCAR=0.0
47  
48 1 my $gen = XML::Generator->new( ':pretty' );
49  
50 return $gen->figure(
51 { class => 'op-slideshow' },
52 1 map { $_->as_xml_gen } @{ $self->_images },
53 );
54 }
55  
56 1 1;
« InstantArticle/Paragraph.pm ↑ Summary InstantArticle/Map.pm »