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

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/WWW/Shopify/Liquid/Debugger.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Optimizer.pm »
1 #!/usr/bin/perl
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use WWW::Shopify::Liquid;
Subroutine BEGIN: called CC=1 SCAR=2.6
7 use WWW::Shopify::Liquid::Element;
8  
9 package WWW::Shopify::Liquid::Filter;
10 use base 'WWW::Shopify::Liquid::Element';
11 sub subelements { qw(operand arguments) }
12  
13 sub new { my $package = shift; my $parser = shift; return bless { line => shift, core => shift, operand => shift, arguments => [@_] }, $package; }
14 # Determines whether or not this acts as a variable with no arguments, when used in conjucntion to a dot on a variable.
15 sub transparent { return 0; }
16 sub name { my $package = ref($_[0]) ? ref($_[0]) : $_[0]; $package =~ s/^.*:://; $package =~ s/([a-z])([A-Z])/$1_$2/g; return lc($package); }
17 sub min_arguments { return 0; }
18 sub max_arguments { return undef; }
19 sub verify {
20 my ($self) = @_;
21 my $count = int(@{$self->{arguments}});
22 die new WWW::Shopify::Liquid::Exception::Parser::Arguments($self, [$count, $self->min_arguments, $self->max_arguments]) if
23 $count < $self->min_arguments || (defined $self->max_arguments && $count > $self->max_arguments);
24 }
25  
26 sub tokens {
27 my ($self) = @_;
28 return ($self, map { $self->is_processed($_) ? $_ : $_->tokens } (@{$_[0]->{arguments}}, $_[0]->{operand}));
29 }
30  
31 sub process {
32 my ($self, $hash, $action, $pipeline) = @_;
33 my ($operand, $arguments) = $self->process_subelements($hash, $action, $pipeline);
34 return $self unless $self->is_processed($operand) && int(grep { !$self->is_processed($_) } @$arguments) == 0;
35 return $self->operate($hash, $operand, @$arguments);
36 }
37  
38 sub stringify {
39 return $_[0]->{core};
40 }
41  
42 package WWW::Shopify::Liquid::Filter::Unknown;
43 use base 'WWW::Shopify::Liquid::Filter';
44  
45 # Don't optimize anything on unknown filters.
46 sub optimize { return $_[0]; }
47  
48 1;
« blib/lib/WWW/Shopify/Liquid/Debugger.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Optimizer.pm »