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

filter: Statementstmt 32.0% 16 / 50 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 33.3% 5 / 15 Podpod 0.0% 0 / 10 totaltotal 20.7% 21 / 101 CC 11 SCAR 24.7
CC
11
Cov
23%
optimize
30.0
verify
20.0
render
12.0
CRAP 11.8
« blib/lib/WWW/Shopify/Liquid/Operator/Array.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Exception.pm »
1 #!/usr/bin/perl
2  
3 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 30 ▶use WWW::Shopify::Liquid;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package WWW::Shopify::Liquid::Filter;
9 30 ▶use base 'WWW::Shopify::Liquid::Element';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub new { my $package = shift; return bless { line => shift, core => shift, operand => shift, arguments => [@_] }, $package; }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
12 # Determines whether or not this acts as a variable with no arguments, when used in conjucntion to a dot on a variable.
13 0 ▶sub transparent { return 0; }
Subroutine transparent: not called CC=1 SCAR=6.9
Pod undocumented
14 0 ▶sub name { my $package = ref($_[0]) ? ref($_[0]) : $_[0]; $package =~ s/^.*:://; $package =~ s/([a-z])([A-Z])/$1_$2/g; return lc($package); }
Subroutine name: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
15 0 ▶sub min_arguments { return 0; }
Subroutine min_arguments: not called CC=1 SCAR=6.9
Pod undocumented
16 0 ▶sub max_arguments { return undef; }
Subroutine max_arguments: not called CC=1 SCAR=6.9
Pod undocumented
17 # Determines whether or not this filter is part of the base Shopify set. By default all filters, unless specified are considered extended.
18 0 ▶sub extended { return 1; }
Subroutine extended: not called CC=1 SCAR=6.9
Pod undocumented
19 sub verify {
20 0 ▶ my ($self) = @_;
Subroutine verify: not called CC=4 SCAR=30.0
Pod undocumented
21 0 my $count = int(@{$self->{arguments}});
22 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self) if
Branch: 1 branch
BranchTrueFalseTotal
if $count < $self->min_arguments or defined $self->max_arguments and $count > $self->max_arguments 0 0 0
Condition0%0/6
$count < $self->min_arguments or defined $self->max_arguments and $count > $self->max_arguments
l!l&&r!l&&!r
000
defined $self->max_arguments and $count > $self->max_arguments
!ll&&!rl&&r
000
MC/DC0%0/3
$count < $self->min_arguments or defined $self->max_arguments and $count > $self->max_arguments
$count < $self->min_arguments defined $self->max_arguments $count > $self->max_arguments
Truth table0%0/4
A or B and C
A= $count < $self->min_argumentsB= defined $self->max_argumentsC= $count > $self->max_arguments
ABCresult
1XX1
0111
00X0
0100
23 $count < $self->min_arguments || (defined $self->max_arguments && $count > $self->max_arguments);
24 }
25  
26 0 ▶sub tokens { return ($_[0], map { $_->tokens } (@{$_[0]->{arguments}}, $_[0]->{operand}->tokens)); }
Subroutine tokens: not called CC=1 SCAR=6.9
Pod undocumented
27  
28 sub render {
29 0 ▶ my ($self, $renderer, $hash) = @_;
Subroutine render: not called CC=3 SCAR=24.8
Pod undocumented
30 0 ▶ my $operand = !$self->is_processed($self->{operand}) ? $self->{operand}->render($renderer, $hash) : $self->{operand};
Branch: 1 branch
BranchTrueFalseTotal
!$self->is_processed($self->{'operand'}) ? : 0 0 0
31 0 ▶ my @arguments = map { !$self->is_processed($_) ? $_->render($renderer, $hash) : $_ } @{$self->{arguments}};
Branch: 1 branch
BranchTrueFalseTotal
!$self->is_processed($_) ? : 0 0 0
32 0 return $self->operate($hash, $operand, @arguments);
33 }
34  
35 sub optimize {
36 0 ▶ my ($self, $optimizer, $hash) = @_;
Subroutine optimize: not called CC=5 SCAR=34.0
Pod undocumented
37 0 ▶ $self->{operand} = $self->{operand}->optimize($optimizer, $hash) unless $self->is_processed($self->{operand});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_processed($self->{"operand"}) 0 0 0
38 0 for (grep { !$self->is_processed($self->{arguments}->[$_]) } 0..int(@{$self->{arguments}})-1) {
39 0 $self->{arguments}->[$_] = $self->{arguments}->[$_]->optimize($optimizer, $hash);
40 }
41 0 ▶ return $self if !$self->is_processed($self->{operand}) || int(grep { !$self->is_processed($_) } @{$self->{arguments}}) > 0;
Branch: 1 branch
BranchTrueFalseTotal
if not $self->is_processed($self->{"operand"}) or int grep({not $self->is_processed($_);} @{$$self{"arguments"};}) > 0 0 0 0
Condition0%0/3
not $self->is_processed($self->{"operand"}) or int grep({not $self->is_processed($_);} @{$$self{"arguments"};}) > 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->is_processed($self->{"operand"}) or int grep({not $self->is_processed($_);} @{$$self{"arguments"};}) > 0
not $self->is_processed($self->{"operand"}) int grep({not $self->is_processed($_);} @{$$self{"arguments"};}) > 0
Truth table0%0/3
not(A) or B
A= not $self->is_processed($self->{"operand"})B= int grep({not $self->is_processed($_);} @{$$self{"arguments"};}) > 0
ABresult
1X1
011
000
42 0 return $self->operate($hash, $self->{operand}, @{$self->{arguments}});
43 }
44  
45  
46 package WWW::Shopify::Liquid::Filter::Unknown;
47 30 ▶use base 'WWW::Shopify::Liquid::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 30 1;
« blib/lib/WWW/Shopify/Liquid/Operator/Array.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Exception.pm »