blib/lib/WWW/Shopify/Liquid/Element.pm

filter: Statementstmt 13.5% 10 / 74 Branchbran 0.0% 0 / 52 Conditioncond 0.0% 0 / 42 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 16.6% 3 / 18 Podpod 0.0% 0 / 15 totaltotal 5.7% 13 / 226 CC 43 SCAR 46.1
CC
43
Cov
6%
render
272.0
render_subelement
110.0
optimize_subelement
30.0
CRAP 100.8
« blib/lib/WWW/Shopify/Liquid/Tag/For.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Tag/Capture.pm »
1  
2 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package WWW::Shopify::Liquid::Element;
6  
7 0 ▶sub verify { return 1; }
Subroutine verify: not called CC=1 SCAR=6.9
Pod undocumented
8  
9 0 ▶sub subelements { qw(); }
Subroutine subelements: not called CC=1 SCAR=6.9
Pod undocumented
10  
11 sub tokens {
12 0 ▶ my ($self) = @_;
Subroutine tokens: not called CC=3 SCAR=24.8
Pod undocumented
13 0 ▶ return ($self, map { $self->is_processed($_) ? $_ : $_->tokens } map { ref($_) eq 'ARRAY' ? @$_ : $_ } map { $self->{$_} } $self->subelements);
Branch: 2 branches
BranchTrueFalseTotal
$self->is_processed($_) ? : 0 0 0
ref $_ eq 'ARRAY' ? : 0 0 0
14 }
15  
16 0 ▶sub operate { return $_[0]; }
Subroutine operate: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 sub render_subelement($$$\$) {
19 0 ▶ my ($self, $renderer, $hash, $element) = @_;
Subroutine render_subelement: not called CC=10 SCAR=47.0
Pod undocumented
20 0 my $value;
21 0 ▶ if (ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq 'ARRAY') { } 0 0 0
22 0 $value = [];
23 0 eval {
24 0 ▶ push(@$value, $self->is_processed($_) ? $_ : ($renderer->state && $renderer->state->{values}->{$_} ? delete $renderer->state->{values}->{$_} : $_->render($renderer, $hash))) for (@$element);
Branch: 2 branches
BranchTrueFalseTotal
$self->is_processed($_) ? : 0 0 0
$renderer->state && $renderer->state->{'values'}{$_} ? : 0 0 0
Condition0%0/3
$renderer->state and $renderer->state->{"values"}{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
$renderer->state and $renderer->state->{"values"}{$_}
$renderer->state $renderer->state->{"values"}{$_}
Truth table0%0/3
A and B
A= $renderer->stateB= $renderer->state->{"values"}{$_}
ABresult
0X0
100
111
25 };
26 0 ▶ if (my $exp = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $exp = $@) 0 0 0
27 0 ▶ $exp->value($element, $value) if blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control::Pause');
Branch: 1 branch
BranchTrueFalseTotal
if &blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause") 0 0 0
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
!ll&&!rl&&r
000
MC/DC0%0/2
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
&blessed($exp) $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
ABresult
0X0
100
111
28 0 die $exp;
29 }
30 } else {
31 0 ▶ $value = !$self->is_processed($$element) ? ($$element)->render($renderer, $hash) : $$element;
Branch: 1 branch
BranchTrueFalseTotal
!$self->is_processed($$element) ? : 0 0 0
32 }
33 0 return $value;
34 }
35  
36 sub optimize_subelement($$$\$) {
37 0 ▶ my ($self, $optimizer, $hash, $element) = @_;
Subroutine optimize_subelement: not called CC=5 SCAR=34.0
Pod undocumented
38 0 my $value;
39 0 ▶ if (ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq 'ARRAY') { } 0 0 0
40 0 for my $idx (0..(int(@$element)-1)) {
41 0 my $inner = $element->[$idx];
42 0 ▶ $element->[$idx] = !$self->is_processed($inner) ? $inner->optimize($optimizer, $hash) : $inner;
Branch: 1 branch
BranchTrueFalseTotal
!$self->is_processed($inner) ? : 0 0 0
43 }
44 } else {
45 0 ▶ $value = !$self->is_processed($$element) ? ($$element)->optimize($optimizer, $hash) : $$element;
Branch: 1 branch
BranchTrueFalseTotal
!$self->is_processed($$element) ? : 0 0 0
46 0 $$element = $value;
47 0 $element = $$element;
48 }
49 0 return $element;
50 }
51  
52 sub process_subelement {
53 0 ▶ my ($self, $hash, $action, $pipeline, $element) = @_;
Subroutine process_subelement: not called CC=1 SCAR=6.9
Pod undocumented
54 0 $action .= "_subelement";
55 0 return $self->$action($pipeline, $hash, $element);
56 }
57  
58 sub process_subelements {
59 0 ▶ my ($self, $hash, $action, $pipeline) = @_;
Subroutine process_subelements: not called CC=2 SCAR=17.9
Pod undocumented
60 0 ▶ return map { $self->process_subelement($hash, $action, $pipeline, ref($self->{$_}) eq 'ARRAY' ? $self->{$_} : (\$self->{$_})) } $self->subelements;
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{$_} eq 'ARRAY' ? : 0 0 0
61 }
62  
63 sub render {
64 0 ▶ my $self = shift;
Subroutine render: not called CC=16 SCAR=56.1
Pod undocumented
65 0 my $renderer = shift;
66 0 ▶ return delete $renderer->state->{values}->{$self} if $renderer->state && exists $renderer->state->{values}->{$self};
Branch: 1 branch
BranchTrueFalseTotal
if $renderer->state and exists $renderer->state->{"values"}{$self} 0 0 0
Condition0%0/3
$renderer->state and exists $renderer->state->{"values"}{$self}
!ll&&!rl&&r
000
MC/DC0%0/2
$renderer->state and exists $renderer->state->{"values"}{$self}
$renderer->state exists $renderer->state->{"values"}{$self}
Truth table0%0/3
A and B
A= $renderer->stateB= exists $renderer->state->{"values"}{$self}
ABresult
0X0
100
111
67 0 my $return = eval { $self->process(@_, "render", $renderer); };
68 0 my $exp = $@;
69 0 ▶ if ($exp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exp) 0 0 0
70 0 ▶ die $exp if (blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control'));
Branch: 1 branch
BranchTrueFalseTotal
if &blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control") 0 0 0
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
!ll&&!rl&&r
000
MC/DC0%0/2
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
&blessed($exp) $exp->isa("WWW::Shopify::Liquid::Exception::Control")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Control")
ABresult
0X0
100
111
71 0 ▶ if ($renderer->{silence_exceptions}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($renderer->{'silence_exceptions'}) { } 0 0 0
elsif ($renderer->{'wrap_exceptions'}) { } 0 0 0
elsif ($renderer->{'print_exceptions'}) { } 0 0 0
72 } elsif ($renderer->{wrap_exceptions}) {
73 0 ▶ die $exp if blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Renderer::Wrapped');
Branch: 1 branch
BranchTrueFalseTotal
if &blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped") 0 0 0
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
!ll&&!rl&&r
000
MC/DC0%0/2
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
&blessed($exp) $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
ABresult
0X0
100
111
74 0 die new WWW::Shopify::Liquid::Exception::Renderer::Wrapped($self, $exp);
75 } elsif ($renderer->{print_exceptions}) {
76 0 ▶ return blessed($exp) && $exp->can('english') ? $exp->english : "$exp";
Branch: 1 branch
BranchTrueFalseTotal
&blessed($exp) && $exp->can('english') ? : 0 0 0
Condition0%0/3
&blessed($exp) and $exp->can("english")
!ll&&!rl&&r
000
MC/DC0%0/2
&blessed($exp) and $exp->can("english")
&blessed($exp) $exp->can("english")
Truth table0%0/3
A and B
A= &blessed($exp)B= $exp->can("english")
ABresult
0X0
100
111
77 } else {
78 0 die $exp;
79 }
80 }
81 0 ▶ return undef if $exp || !$self->is_processed($return) || !defined $return;
Branch: 1 branch
BranchTrueFalseTotal
if $exp or not $self->is_processed($return) or not defined $return 0 0 0
Condition0%0/6
$exp or not $self->is_processed($return) or not defined $return
l!l&&r!l&&!r
000
$exp or not $self->is_processed($return)
l!l&&r!l&&!r
000
MC/DC0%0/3
$exp or not $self->is_processed($return) or not defined $return
$exp not $self->is_processed($return) not defined $return
Truth table0%0/4
A or not(B) or not(C)
A= $expB= not $self->is_processed($return)C= not defined $return
ABCresult
1XX1
01X1
0011
0000
82 0 return $return;
83 }
84  
85 sub get_parameter {
86 0 ▶ my ($self, $name, @arguments) = @_;
Subroutine get_parameter: not called CC=5 SCAR=34.0
Pod undocumented
87 0 ▶ my ($arg) = grep { ref($_) && ref($_) eq 'HASH' && int(keys(%$_)) == 1 && exists $_->{$name} } @arguments;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ and ref $_ eq "HASH" and int keys %$_ == 1 and exists $_->{$name} 0 0 0
Condition0%0/6
ref $_ and ref $_ eq "HASH" and int keys %$_ == 1
!ll&&!rl&&r
000
ref $_ and ref $_ eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
ref $_ and ref $_ eq "HASH" and int keys %$_ == 1
ref $_ ref $_ eq "HASH" int keys %$_ == 1
Truth table0%0/4
A and B and C
A= ref $_B= ref $_ eq "HASH"C= int keys %$_ == 1
ABCresult
0XX0
10X0
1100
1111
88 0 ▶ return $arg ? $arg->{$name} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$arg ? : 0 0 0
89 }
90  
91 sub optimize {
92 0 ▶ my $self = shift;
Subroutine optimize: not called CC=4 SCAR=30.0
Pod undocumented
93 0 my $optimizer = shift;
94 0 ▶ die new WWW::Shopify::Liquid::Exception($self, "Cannot optimize without a valid optimizer.")
Branch: 1 branch
BranchTrueFalseTotal
unless $optimizer and &blessed($optimizer) and $optimizer->isa("WWW::Shopify::Liquid::Optimizer") 0 0 0
Condition0%0/6
$optimizer and &blessed($optimizer) and $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
!ll&&!rl&&r
000
$optimizer and &blessed($optimizer)
!ll&&!rl&&r
000
MC/DC0%0/3
$optimizer and &blessed($optimizer) and $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
$optimizer &blessed($optimizer) $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
Truth table0%0/4
A and B and C
A= $optimizerB= &blessed($optimizer)C= $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
ABCresult
0XX0
10X0
1100
1111
95 unless $optimizer && blessed($optimizer) && $optimizer->isa('WWW::Shopify::Liquid::Optimizer');
96 0 return $self->process(@_, "optimize", $optimizer);
97 }
98 0 ▶sub process { return $_[0]; }
Subroutine process: not called CC=1 SCAR=6.9
Pod undocumented
99 # Determines whether or not the element is part of the strict subset of liquid that Shopify uses.
100 0 ▶sub is_strict { return 0; }
Subroutine is_strict: not called CC=1 SCAR=6.9
Pod undocumented
101  
102 37 ▶use Scalar::Util qw(looks_like_number blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
103  
104 0 ▶sub is_processed { return WWW::Shopify::Liquid::Pipeline->is_processed($_[1]); }
Subroutine is_processed: not called CC=1 SCAR=6.9
Pod undocumented
105 sub ensure_numerical {
106 0 ▶ return $_[1] if defined $_[1] && looks_like_number($_[1]);
Subroutine ensure_numerical: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] and &looks_like_number($_[1]) 0 0 0
Condition0%0/3
defined $_[1] and &looks_like_number($_[1])
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[1] and &looks_like_number($_[1])
defined $_[1] &looks_like_number($_[1])
Truth table0%0/3
A and B
A= defined $_[1]B= &looks_like_number($_[1])
ABresult
0X0
100
111
107 0 ▶ return $_[1] if ref($_[1]) && ref($_[1]) eq "DateTime";
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[1] and ref $_[1] eq "DateTime" 0 0 0
Condition0%0/3
ref $_[1] and ref $_[1] eq "DateTime"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[1] and ref $_[1] eq "DateTime"
ref $_[1] ref $_[1] eq "DateTime"
Truth table0%0/3
A and B
A= ref $_[1]B= ref $_[1] eq "DateTime"
ABresult
0X0
100
111
108 0 return 0;
109 }
110  
111 37 1;
« blib/lib/WWW/Shopify/Liquid/Tag/For.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Tag/Capture.pm »