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

filter: Statementstmt 63.3% 19 / 30 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 2 totaltotal 24.5% 25 / 102 CC 21 SCAR 46.7
CC
21
Cov
25%
walk_data
156.0
operate
110.0
BEGIN
1.0
CRAP 106.4
« lib/WWW/Shopify/Liquid/Tag/Decrement.pm ↑ Summary lib/WWW/Shopify/Liquid/Element.pm »
1 #!/usr/bin/perl
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 38 ▶package WWW::Shopify::Liquid::Filter::JSON; use base 'WWW::Shopify::Liquid::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 38 ▶use JSON qw(encode_json decode_json from_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 38 ▶use Scalar::Util qw(blessed isweak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 38 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub walk_data {
Subroutine walk_data: not called CC=12 SCAR=50.5
Pod undocumented
11 0 my ($self) = @_;
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 0 ▶sub operate {
Subroutine operate: not called CC=10 SCAR=47.0
Pod undocumented
21 # We allow decoding with this filter as well.
22 0 ▶ if (defined $_[2] && !ref($_[2]) && length($_[2]) >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[2] and not ref $_[2] and length $_[2] >= 2) 0 0 0
Condition0%0/6
defined $_[2] and not ref $_[2] and length $_[2] >= 2
!ll&&!rl&&r
000
defined $_[2] and not ref $_[2]
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_[2] and not ref $_[2] and length $_[2] >= 2
defined $_[2] not ref $_[2] length $_[2] >= 2
Truth table0%0/4
A and not(B) and C
A= defined $_[2]B= not ref $_[2]C= length $_[2] >= 2
ABCresult
0XX0
10X0
1100
1111
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 38 1;
« lib/WWW/Shopify/Liquid/Tag/Decrement.pm ↑ Summary lib/WWW/Shopify/Liquid/Element.pm »