lib/WWW/Shopify/Liquid/Element.pm

filter: Statementstmt 13.1% 10 / 76 Branchbran 0.0% 0 / 50 Conditioncond 0.0% 0 / 45 MC/DCmcdc 0.0% 0 / 26 Subroutinesub 16.6% 3 / 18 Podpod 0.0% 0 / 15 totaltotal 5.6% 13 / 230 CC 43 SCAR 46.1
CC
43
Cov
6%
render
272.0
render_subelement
110.0
optimize_subelement
30.0
CRAP 100.8
« lib/WWW/Shopify/Liquid/Filter/JSON.pm ↑ Summary lib/WWW/Shopify/Liquid/Tag/If.pm »
1  
2 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 38 ▶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 0 ▶sub tokens {
Subroutine tokens: not called CC=3 SCAR=24.8
Pod undocumented
12 0 my ($self) = @_;
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 0 ▶sub render_subelement($$$\$) {
Subroutine render_subelement: not called CC=10 SCAR=47.0
Pod undocumented
19 0 my ($self, $renderer, $hash, $element) = @_;
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 0 ▶sub optimize_subelement($$$\$) {
Subroutine optimize_subelement: not called CC=5 SCAR=34.0
Pod undocumented
37 0 my ($self, $optimizer, $hash, $element) = @_;
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 ▶ if (!$self->is_processed($inner)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_processed($inner)) 0 0 0
43 0 $inner = $inner->optimize($optimizer, $hash);
44 0 $element->[$idx] = $inner
45 }
46 }
47 } else {
48 0 ▶ $value = !$self->is_processed($$element) ? ($$element)->optimize($optimizer, $hash) : $$element;
Branch: 1 branch
BranchTrueFalseTotal
!$self->is_processed($$element) ? : 0 0 0
49 0 $$element = $value;
50 0 $element = $$element;
51 }
52 0 return $element;
53 }
54  
55 0 ▶sub process_subelement {
Subroutine process_subelement: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my ($self, $hash, $action, $pipeline, $element) = @_;
57 0 $action .= "_subelement";
58 0 return $self->$action($pipeline, $hash, $element);
59 }
60  
61 0 ▶sub process_subelements {
Subroutine process_subelements: not called CC=2 SCAR=17.9
Pod undocumented
62 0 my ($self, $hash, $action, $pipeline) = @_;
63 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
64 }
65  
66 0 ▶sub render {
Subroutine render: not called CC=16 SCAR=56.1
Pod undocumented
67 0 my $self = shift;
68 0 my $renderer = shift;
69 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
70 0 my $return = eval { $self->process(@_, "render", $renderer); };
71 0 my $exp = $@;
72 0 ▶ if ($exp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exp) 0 0 0
73 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
74 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
75 } elsif ($renderer->{wrap_exceptions}) {
76 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
77 0 die new WWW::Shopify::Liquid::Exception::Renderer::Wrapped($self, $exp);
78 } elsif ($renderer->{print_exceptions}) {
79 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
80 } else {
81 0 die $exp;
82 }
83 }
84 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
85 0 return $return;
86 }
87  
88 0 ▶sub get_parameter {
Subroutine get_parameter: not called CC=5 SCAR=34.0
Pod undocumented
89 0 my ($self, $name, @arguments) = @_;
90 0 ▶ my ($arg) = grep { ref($_) && ref($_) eq 'HASH' && int(keys(%$_)) == 1 && exists $_->{$name} } @arguments;
Condition0%0/9
ref $_ && ref $_ eq 'HASH' && int keys %$_ == 1 && exists $_->{$name}
!ll&&!rl&&r
000
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/4
ref $_ && ref $_ eq 'HASH' && int keys %$_ == 1 && exists $_->{$name}
ref $_ ref $_ eq "HASH" int keys %$_ == 1 exists $_->{$name}
Truth table0%0/5
A and B and C && D
A= ref $_B= ref $_ eq "HASH"C= int keys %$_ == 1D= exists $_->{$name}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
91 0 ▶ return $arg ? $arg->{$name} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$arg ? : 0 0 0
92 }
93  
94 0 ▶sub optimize {
Subroutine optimize: not called CC=4 SCAR=30.0
Pod undocumented
95 0 my $self = shift;
96 0 my $optimizer = shift;
97 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
98 unless $optimizer && blessed($optimizer) && $optimizer->isa('WWW::Shopify::Liquid::Optimizer');
99 0 return $self->process(@_, "optimize", $optimizer);
100 }
101 0 ▶sub process { return $_[0]; }
Subroutine process: not called CC=1 SCAR=6.9
Pod undocumented
102 # Determines whether or not the element is part of the strict subset of liquid that Shopify uses.
103 0 ▶sub is_strict { return 0; }
Subroutine is_strict: not called CC=1 SCAR=6.9
Pod undocumented
104  
105 38 ▶use Scalar::Util qw(looks_like_number blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
106  
107 0 ▶sub is_processed { return WWW::Shopify::Liquid::Pipeline->is_processed($_[1]); }
Subroutine is_processed: not called CC=1 SCAR=6.9
Pod undocumented
108 0 ▶sub ensure_numerical {
Subroutine ensure_numerical: not called CC=5 SCAR=34.0
Pod undocumented
109 0 ▶ return $_[1] if defined $_[1] && looks_like_number($_[1]);
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
110 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
111 0 return 0;
112 }
113  
114 38 1;
« lib/WWW/Shopify/Liquid/Filter/JSON.pm ↑ Summary lib/WWW/Shopify/Liquid/Tag/If.pm »