| 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
Condition33%1/3
%opts or $Data::Clean::ForJSON::creating_singleton
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
| |||||||||||||||||||||||||||||
| 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"]
MC/DC0%0/1
$opts{"DateTime"} //= ["call_method", "epoch"]
$opts{"DateTime"}
Truth table50%1/2
A
A= $opts{"DateTime"}
| |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | $opts{'Time::Moment'} //= [call_method => 'epoch']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"Time::Moment"} //= ["call_method", "epoch"]
MC/DC0%0/1
$opts{"Time::Moment"} //= ["call_method", "epoch"]
$opts{"Time::Moment"}
Truth table50%1/2
A
A= $opts{"Time::Moment"}
| |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | $opts{'Math::BigInt'} //= [call_method => 'bstr']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"Math::BigInt"} //= ["call_method", "bstr"]
MC/DC0%0/1
$opts{"Math::BigInt"} //= ["call_method", "bstr"]
$opts{"Math::BigInt"}
Truth table50%1/2
A
A= $opts{"Math::BigInt"}
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | $opts{Regexp} //= ['stringify']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"Regexp"} //= ["stringify"]
MC/DC0%0/1
$opts{"Regexp"} //= ["stringify"]
$opts{"Regexp"}
Truth table50%1/2
A
A= $opts{"Regexp"}
| |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | $opts{version} //= ['stringify']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"version"} //= ["stringify"]
MC/DC0%0/1
$opts{"version"} //= ["stringify"]
$opts{"version"}
Truth table50%1/2
A
A= $opts{"version"}
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | $opts{SCALAR} //= ['deref_scalar']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"SCALAR"} //= ["deref_scalar"]
MC/DC0%0/1
$opts{"SCALAR"} //= ["deref_scalar"]
$opts{"SCALAR"}
Truth table50%1/2
A
A= $opts{"SCALAR"}
| |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | $opts{-ref} //= ['replace_with_ref']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"-ref"} //= ["replace_with_ref"]
MC/DC0%0/1
$opts{"-ref"} //= ["replace_with_ref"]
$opts{"-ref"}
Truth table50%1/2
A
A= $opts{"-ref"}
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | $opts{-circular} //= ['clone']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"-circular"} //= ["clone"]
MC/DC0%0/1
$opts{"-circular"} //= ["clone"]
$opts{"-circular"}
Truth table50%1/2
A
A= $opts{"-circular"}
| |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | $opts{-obj} //= ['unbless']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"-obj"} //= ["unbless"]
MC/DC0%0/1
$opts{"-obj"} //= ["unbless"]
$opts{"-obj"}
Truth table50%1/2
A
A= $opts{"-obj"}
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | $opts{'!recurse_obj'} //= 1; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"!recurse_obj"} //= 1
MC/DC0%0/1
$opts{"!recurse_obj"} //= 1
$opts{"!recurse_obj"}
Truth table50%1/2
A
A= $opts{"!recurse_obj"}
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||