ForJSON.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 50.0% 1 / 2 Conditioncond 47.8% 11 / 23 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 90.0% 9 / 10 Podpod 100% 4 / 4 totaltotal 69.5% 64 / 92 CC 13 SCAR 25.5
CC
13
Cov
77%
new
20.8
clone_and_clean_json
2.0
BEGIN
1.0
CRAP 12.8
↑ Summary FromJSON.pm »
1 package Data::Clean::ForJSON;
2  
3 2 our $DATE = '2019-11-26'; # DATE
4 2 our $VERSION = '0.395'; # VERSION
5  
6 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use parent qw(Data::Clean);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use vars qw($creating_singleton);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 our @EXPORT_OK = qw(
15 clean_json_in_place
16 clone_and_clean_json
17 );
18  
19 1 ▶sub new {
Subroutine new: called CC=13 SCAR=30.4
Pod documented
20 1 my ($class, %opts) = @_;
21  
22 1 ▶ if (!%opts && !$creating_singleton) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%opts or $Data::Clean::ForJSON::creating_singleton) 0 1 1
Condition33%1/3
%opts or $Data::Clean::ForJSON::creating_singleton
l!l&&r!l&&!r
010
MC/DC0%0/2
%opts or $Data::Clean::ForJSON::creating_singleton
%opts $Data::Clean::ForJSON::creating_singleton
Truth table33%1/3
A or B
A= %optsB= $Data::Clean::ForJSON::creating_singleton
ABresult
1X1
011
000
23 0 warn "You are creating a new ".__PACKAGE__." object without customizing options. ".
24 "You probably want to call get_cleanser() yet to get a singleton instead?";
25 }
26  
27 1 ▶ $opts{DateTime} //= [call_method => 'epoch'];
Condition50%1/2
$opts{"DateTime"} //= ["call_method", "epoch"]
l!l
01
MC/DC0%0/1
$opts{"DateTime"} //= ["call_method", "epoch"]
$opts{"DateTime"}
Truth table50%1/2
A
A= $opts{"DateTime"}
Aresult
11
00
28 1 ▶ $opts{'Time::Moment'} //= [call_method => 'epoch'];
Condition50%1/2
$opts{"Time::Moment"} //= ["call_method", "epoch"]
l!l
01
MC/DC0%0/1
$opts{"Time::Moment"} //= ["call_method", "epoch"]
$opts{"Time::Moment"}
Truth table50%1/2
A
A= $opts{"Time::Moment"}
Aresult
11
00
29 1 ▶ $opts{'Math::BigInt'} //= [call_method => 'bstr'];
Condition50%1/2
$opts{"Math::BigInt"} //= ["call_method", "bstr"]
l!l
01
MC/DC0%0/1
$opts{"Math::BigInt"} //= ["call_method", "bstr"]
$opts{"Math::BigInt"}
Truth table50%1/2
A
A= $opts{"Math::BigInt"}
Aresult
11
00
30 1 ▶ $opts{Regexp} //= ['stringify'];
Condition50%1/2
$opts{"Regexp"} //= ["stringify"]
l!l
01
MC/DC0%0/1
$opts{"Regexp"} //= ["stringify"]
$opts{"Regexp"}
Truth table50%1/2
A
A= $opts{"Regexp"}
Aresult
11
00
31 1 ▶ $opts{version} //= ['stringify'];
Condition50%1/2
$opts{"version"} //= ["stringify"]
l!l
01
MC/DC0%0/1
$opts{"version"} //= ["stringify"]
$opts{"version"}
Truth table50%1/2
A
A= $opts{"version"}
Aresult
11
00
32  
33 1 ▶ $opts{SCALAR} //= ['deref_scalar'];
Condition50%1/2
$opts{"SCALAR"} //= ["deref_scalar"]
l!l
01
MC/DC0%0/1
$opts{"SCALAR"} //= ["deref_scalar"]
$opts{"SCALAR"}
Truth table50%1/2
A
A= $opts{"SCALAR"}
Aresult
11
00
34 1 ▶ $opts{-ref} //= ['replace_with_ref'];
Condition50%1/2
$opts{"-ref"} //= ["replace_with_ref"]
l!l
01
MC/DC0%0/1
$opts{"-ref"} //= ["replace_with_ref"]
$opts{"-ref"}
Truth table50%1/2
A
A= $opts{"-ref"}
Aresult
11
00
35 1 ▶ $opts{-circular} //= ['clone'];
Condition50%1/2
$opts{"-circular"} //= ["clone"]
l!l
01
MC/DC0%0/1
$opts{"-circular"} //= ["clone"]
$opts{"-circular"}
Truth table50%1/2
A
A= $opts{"-circular"}
Aresult
11
00
36 1 ▶ $opts{-obj} //= ['unbless'];
Condition50%1/2
$opts{"-obj"} //= ["unbless"]
l!l
01
MC/DC0%0/1
$opts{"-obj"} //= ["unbless"]
$opts{"-obj"}
Truth table50%1/2
A
A= $opts{"-obj"}
Aresult
11
00
37  
38 1 ▶ $opts{'!recurse_obj'} //= 1;
Condition50%1/2
$opts{"!recurse_obj"} //= 1
l!l
01
MC/DC0%0/1
$opts{"!recurse_obj"} //= 1
$opts{"!recurse_obj"}
Truth table50%1/2
A
A= $opts{"!recurse_obj"}
Aresult
11
00
39 1 $class->SUPER::new(%opts);
40 }
41  
42 2 ▶sub get_cleanser {
Subroutine get_cleanser: called CC=1 SCAR=0.0
Pod documented
43 2 my $class = shift;
44 2 local $creating_singleton = 1;
45 2 state $singleton = $class->new;
46 2 $singleton;
47 }
48  
49 1 ▶sub clean_json_in_place {
Subroutine clean_json_in_place: called CC=1 SCAR=0.0
Pod documented
50 1 __PACKAGE__->get_cleanser->clean_in_place(@_);
51 }
52  
53 0 ▶sub clone_and_clean_json {
Subroutine clone_and_clean_json: not called CC=1 SCAR=6.9
Pod documented
54 0 __PACKAGE__->get_cleanser->clone_and_clean(@_);
55 }
56  
57 2 1;
58 # ABSTRACT: Clean data so it is safe to output to JSON
59  
60 __END__
↑ Summary FromJSON.pm »