| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$renderer->state and $renderer->state->{"values"}{$_}
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"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if (my $exp = $@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $exp->value($element, $value) if blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control::Pause'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control::Pause")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $value = !$self->is_processed($$element) ? ($$element)->render($renderer, $hash) : $$element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $value = !$self->is_processed($$element) ? ($$element)->optimize($optimizer, $hash) : $$element; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$renderer->state and exists $renderer->state->{"values"}{$self}
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}
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $return = eval { $self->process(@_, "render", $renderer); }; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my $exp = $@; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($exp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | die $exp if (blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Control')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Control")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($renderer->{silence_exceptions}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | } elsif ($renderer->{wrap_exceptions}) { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | die $exp if blessed($exp) && $exp->isa('WWW::Shopify::Liquid::Exception::Renderer::Wrapped'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&blessed($exp) and $exp->isa("WWW::Shopify::Liquid::Exception::Renderer::Wrapped")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
&blessed($exp) and $exp->can("english")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | die $exp; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return undef if $exp || !$self->is_processed($return) || !defined $return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$exp or not $self->is_processed($return) or not defined $return
$exp or not $self->is_processed($return)
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
ref $_ and ref $_ eq "HASH" and int keys %$_ == 1
ref $_ and ref $_ eq "HASH"
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
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return $arg ? $arg->{$name} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$optimizer and &blessed($optimizer) and $optimizer->isa("WWW::Shopify::Liquid::Optimizer")
$optimizer and &blessed($optimizer)
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
defined $_[1] and &looks_like_number($_[1])
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])
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return $_[1] if ref($_[1]) && ref($_[1]) eq "DateTime"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[1] and ref $_[1] eq "DateTime"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 37 | 1; | |||||||||||||||||||||||||||||||||||||||||