| 1 | package Facebook::InstantArticle::Embed; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | extends 'Facebook::InstantArticle::BaseElement'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | has 'content' => ( | |||||||||||||||||||||||||||
| 8 | isa => 'Str', | ||||||||||||||||||||||||||||
| 9 | is => 'rw', | ||||||||||||||||||||||||||||
| 10 | required => 0, | ||||||||||||||||||||||||||||
| 11 | default => '', | ||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | has 'source' => ( | |||||||||||||||||||||||||||
| 15 | isa => 'Str', | ||||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | required => 0, | ||||||||||||||||||||||||||||
| 18 | default => '', | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | has 'width' => ( | |||||||||||||||||||||||||||
| 22 | isa => 'Int', | ||||||||||||||||||||||||||||
| 23 | is => 'rw', | ||||||||||||||||||||||||||||
| 24 | required => 0, | ||||||||||||||||||||||||||||
| 25 | default => 0, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | has 'height' => ( | |||||||||||||||||||||||||||
| 29 | isa => 'Int', | ||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||
| 31 | required => 0, | ||||||||||||||||||||||||||||
| 32 | default => 0, | ||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | around BUILDARGS => sub { | ||||||||||||||||||||||||||||
| 36 | 1 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||
| 37 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | if ( @_ == 1 && !ref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and not ref $_[0]
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 40 | 0 | return $class->$orig( content => $_[0] ); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | 1 | return $class->$orig( @_ ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 2 | }; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | has 'is_valid' => ( | ||||||||||||||||||||||||||||
| 48 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 49 | is => 'ro', | ||||||||||||||||||||||||||||
| 50 | lazy => 1, | ||||||||||||||||||||||||||||
| 51 | default => sub { | ||||||||||||||||||||||||||||
| 52 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | ▶ | return ( length $self->content || length $self->source ) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $self->content or length $self->source
MC/DC0%0/2
length $self->content or length $self->source
length $self->content
length $self->source
Truth table33%1/3
A or B
A= length $self->contentB= length $self->source
| |||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||
| 56 | 2 | ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | has 'as_xml_gen' => ( | |||||||||||||||||||||||||||
| 59 | isa => 'Object', | ||||||||||||||||||||||||||||
| 60 | is => 'ro', | ||||||||||||||||||||||||||||
| 61 | lazy => 1, | ||||||||||||||||||||||||||||
| 62 | builder => '_build_as_xml_gen', | ||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | sub _build_as_xml_gen { | ||||||||||||||||||||||||||||
| 66 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_as_xml_gen: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | my $gen = XML::Generator->new( ':pretty' ); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | my %attrs = (); | |||||||||||||||||||||||||||
| 71 | 1 | ▶ | $attrs{ src } = $self->source if ( length $self->source ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | $attrs{ width } = $self->width if ( $self->width ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | $attrs{ height } = $self->height if ( $self->height ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 1 | ▶ | return $gen->figure( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | { class => 'op-interactive' }, | ||||||||||||||||||||||||||||
| 77 | $gen->iframe( | ||||||||||||||||||||||||||||
| 78 | ( keys %attrs ? \%attrs : undef ), | ||||||||||||||||||||||||||||
| 79 | \$self->content, | ||||||||||||||||||||||||||||
| 80 | ), | ||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 2 | 1; | |||||||||||||||||||||||||||