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

filter: Statementstmt 63.3% 19 / 30 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 2 totaltotal 25.5% 25 / 98 CC 20 SCAR 46.0
CC
20
Cov
26%
walk_data
156.0
operate
90.0
BEGIN
1.0
CRAP 99.6
« blib/lib/WWW/Shopify/Liquid/Tag/Decrement.pm ↑ Summary blib/lib/WWW/Shopify/Liquid.pm »
1 #!/usr/bin/perl
2 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 30 ▶package WWW::Shopify::Liquid::Filter::JSON; use base 'WWW::Shopify::Liquid::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use JSON qw(encode_json decode_json from_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 ▶use Scalar::Util qw(blessed isweak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 30 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub walk_data {
11 0 ▶ my ($self) = @_;
Subroutine walk_data: not called CC=12 SCAR=50.5
Pod undocumented
12 0 ▶ if (ref($self) && ref($self) eq "ARRAY" && !isweak($self)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self and ref $self eq 'ARRAY' and not builtin::is_weak($self)) { } 0 0 0
elsif (ref $self and ref $self eq 'HASH' and not builtin::is_weak($self)) { } 0 0 0
Condition0%0/6
ref $self and ref $self eq "ARRAY" and not builtin::is_weak($self)
!ll&&!rl&&r
000
ref $self and ref $self eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
ref $self and ref $self eq "ARRAY" and not builtin::is_weak($self)
ref $self ref $self eq "ARRAY" not builtin::is_weak($self)
Truth table0%0/4
A and B and not(C)
A= ref $selfB= ref $self eq "ARRAY"C= not builtin::is_weak($self)
ABCresult
0XX0
10X0
1100
1111
13 0 $self->[$_] = walk_data($self->[$_]) for (0..int(@$self)-1);
14 ▶ } elsif (ref($self) && ref($self) eq "HASH" && !isweak($self)) {
Condition0%0/6
ref $self and ref $self eq "HASH" and not builtin::is_weak($self)
!ll&&!rl&&r
000
ref $self and ref $self eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
ref $self and ref $self eq "HASH" and not builtin::is_weak($self)
ref $self ref $self eq "HASH" not builtin::is_weak($self)
Truth table0%0/4
A and B and not(C)
A= ref $selfB= ref $self eq "HASH"C= not builtin::is_weak($self)
ABCresult
0XX0
10X0
1100
1111
15 0 $self->{$_} = walk_data($self->{$_}) for (keys(%$self));
16 }
17 0 ▶ return defined $self && blessed($self) && $self->isa('DateTime') ? $self->iso8601 : $self;
Branch: 1 branch
BranchTrueFalseTotal
defined $self && builtin::blessed($self) && $self->isa('DateTime') ? : 0 0 0
Condition0%0/6
defined $self and builtin::blessed($self) and $self->isa("DateTime")
!ll&&!rl&&r
000
defined $self and builtin::blessed($self)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self and builtin::blessed($self) and $self->isa("DateTime")
defined $self builtin::blessed($self) $self->isa("DateTime")
Truth table0%0/4
A and B and C
A= defined $selfB= builtin::blessed($self)C= $self->isa("DateTime")
ABCresult
0XX0
10X0
1100
1111
18 }
19  
20 sub operate {
21 # We allow decoding with this filter as well.
22 0 ▶ if (!ref($_[2]) && length($_[2]) >= 2) {
Subroutine operate: not called CC=9 SCAR=45.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $_[2] and length $_[2] >= 2) 0 0 0
Condition0%0/3
not ref $_[2] and length $_[2] >= 2
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $_[2] and length $_[2] >= 2
not ref $_[2] length $_[2] >= 2
Truth table0%0/3
not(A) and B
A= not ref $_[2]B= length $_[2] >= 2
ABresult
0X0
100
111
23 0 my $object = eval { from_json($_[2]) };
24 0 ▶ return $object if !$@;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ 0 0 0
25 }
26 0 ▶ my $object = $_[2] ? (blessed($_[2]) && $_[2]->isa('WWW::Shopify::Model::Item') ? WWW::Shopify::Liquid->liquify_item($_[2]) : walk_data(clone($_[2]))) : $_[2];
Branch: 2 branches
BranchTrueFalseTotal
$_[2] ? : 0 0 0
builtin::blessed($_[2]) && $_[2]->isa('WWW::Shopify::Model::Item') ? : 0 0 0
Condition0%0/3
builtin::blessed($_[2]) and $_[2]->isa("WWW::Shopify::Model::Item")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_[2]) and $_[2]->isa("WWW::Shopify::Model::Item")
builtin::blessed($_[2]) $_[2]->isa("WWW::Shopify::Model::Item")
Truth table0%0/3
A and B
A= builtin::blessed($_[2])B= $_[2]->isa("WWW::Shopify::Model::Item")
ABresult
0X0
100
111
27 0 ▶ return defined $object && ref($object) ? JSON->new->allow_blessed(1)->encode($object) : '{}';
Branch: 1 branch
BranchTrueFalseTotal
defined $object && ref $object ? : 0 0 0
Condition0%0/3
defined $object and ref $object
!ll&&!rl&&r
000
MC/DC0%0/2
defined $object and ref $object
defined $object ref $object
Truth table0%0/3
A and B
A= defined $objectB= ref $object
ABresult
0X0
100
111
28 }
29  
30 30 1;
« blib/lib/WWW/Shopify/Liquid/Tag/Decrement.pm ↑ Summary blib/lib/WWW/Shopify/Liquid.pm »