| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Module Generic - ~/lib/Module/Generic/Hash.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v1.5.3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2021/03/20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/01/22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package Module::Generic::Hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | warnings::register_categories( 'Module::Generic' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use vars qw( $VERSION $DEBUG $KEY_OBJECT $NUMBER_RE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | ▶ | use Clone (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | ▶ | use Module::Generic::TieHash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # use Regexp::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | ▶ | use Wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 8 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # '""' => 'as_string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | 'eq' => sub { _obj_eq(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | 'ne' => sub { !_obj_eq(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | '<' => sub { _obj_comp( @_, '<') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | '>' => sub { _obj_comp( @_, '>') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | '<=' => sub { _obj_comp( @_, '<=') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | '>=' => sub { _obj_comp( @_, '>=') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | '==' => sub { _obj_comp( @_, '>=') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | '!=' => sub { _obj_comp( @_, '>=') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | 'lt' => sub { _obj_comp( @_, 'lt') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | 'gt' => sub { _obj_comp( @_, 'gt') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | 'le' => sub { _obj_comp( @_, 'le') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | 'ge' => sub { _obj_comp( @_, 'ge') }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 91 | ▶ | 'bool' => sub{$_[0]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # Do we allow the use of object as hash keys? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | our $KEY_OBJECT = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | our $NUMBER_RE = qr/(?:(?i)(?:[-+]?)(?:(?=[.]?[0123456789])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[-+]?)(?:[0123456789]+))|))/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | our( $VERSION ) = 'v1.5.3'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 8 | require Module::Generic::Array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | require Module::Generic::Number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 8 | require Module::Generic::Scalar; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 38 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=29.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 38 | my $that = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 38 | ▶ | my $class = ref( $that ) || $that; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table66%2/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 38 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # This enables access to the hash just like a real hash while still the user an call our object methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 38 | my $obj = tie( %hash, 'Module::Generic::TieHash', { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # disable => ['Module::Generic'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | debug => $DEBUG, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | enable => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # Should we allow objects to be used as key? Default to false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | key_object => $KEY_OBJECT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 38 | my $self = bless( \%hash => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 38 | $obj->enable(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 38 | ▶ | if( scalar( @_ ) == 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 30 | my $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 30 | ▶ | if( defined( $data ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 30 | ▶ | return( $that->error( "I was expecting an hash, but instead got '", ( $data // 'undef' ), "'." ) ) if( Scalar::Util::reftype( $data // '' ) ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%1/4
$data // ""
$data // "undef"
MC/DC0%0/1
$data // ""
$data
MC/DC0%0/1
$data // "undef"
$data
Truth table50%1/2
A
A= $data
Truth table0%0/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 30 | my $tied = tied( %$data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 30 | ▶ | return( $that->error( "Hash provided is already tied to ", ref( $tied ), " and our package $class cannot use it, or it would disrupt the tie." ) ) if( $tied ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 30 | my @keys = CORE::keys( %$data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 30 | @hash{ @keys } = @$data{ @keys }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ▶ | elsif( scalar( @_ ) > 1 && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
scalar @_ > 1 and not @_ % 2
MC/DC0%0/2
scalar @_ > 1 and not @_ % 2
scalar @_ > 1
not @_ % 2
Truth table33%1/3
A and not(B)
A= scalar @_ > 1B= not @_ % 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | !( @_ % 2 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | while( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $hash{ shift( @_ ) } = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | elsif( scalar( @_ ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return( $self->error( "Odd number (", scalar( @_ ), ") of hash keys and values provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 38 | $obj->enable(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 38 | $self->SUPER::init( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 38 | $obj->enable(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 38 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # sub as_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # my $self = CORE::shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # my $hash = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # $self->_tie_object->enable(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # my $keys = $self->keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # @$hash{ @$keys } = @$self{ @$keys }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # return( $hash ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # We are already an hash, so no need to do anything. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # To convert to a regular hash as needed by JSON, the method TO_JSON can be used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | sub as_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if( $opts->{strict} || $opts->{native} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts->{"strict"} or $opts->{"native"}
MC/DC0%0/2
$opts->{"strict"} or $opts->{"native"}
$opts->{"strict"}
$opts->{"native"}
Truth table0%0/3
A or B
A= $opts->{"strict"}B= $opts->{"native"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $ref = { %$self }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return( $ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | sub as_json { return( shift->json(@_)->scalar ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_json: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | sub as_string { return( shift->dump ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | sub chomp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chomp: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | CORE::chomp( %$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | sub clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 5 | my $data = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | my $clone = Clone::clone( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | return( $self->new( $clone ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # sub debug { return( shift->_internal( 'debug', '_set_get_number', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # sub debug { return( shift->_super_method( 'debug', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub debug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my $rv = $self->SUPER::debug( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | ▶ | sub defined { CORE::defined( $_[0]->{ $_[1] } ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defined: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | sub delete { return( CORE::delete( shift->{ shift( @_ ) } ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | sub dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | return( $self->_dumper( $self ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | sub each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | my $code = shift( @_ ) || return( $self->error( "No subroutine callback as provided for each" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return $self->error('No subroutine callback as provided for each'))
MC/DC0%0/1
shift @_ || (return $self->error('No subroutine callback as provided for each'))
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | return( $self->error( "I was expecting a reference to a subroutine for the callback to each, but got '$code' instead." ) ) if( ref( $code ) ne 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | while( my( $k, $v ) = CORE::each( %$self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | ▶ | CORE::defined( $code->( $k, $v ) ) || CORE::last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | sub error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my( @rv, $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if( wantarray ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | @rv = $self->SUPER::error( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return( @rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $rv2 = $self->SUPER::error( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return( $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | ▶ | sub exists { return( CORE::exists( shift->{ shift( @_ ) } ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | ▶ | sub for { return( shift->foreach( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub foreach | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foreach: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | my $code = shift( @_ ) || return( $self->error( "No subroutine callback as provided for each" ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return $self->error('No subroutine callback as provided for each'))
MC/DC0%0/1
shift @_ || (return $self->error('No subroutine callback as provided for each'))
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | ▶ | return( $self->error( "I was expecting a reference to a subroutine for the callback to each, but got '$code' instead." ) ) if( ref( $code ) ne 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | CORE::foreach my $k ( CORE::keys( %$self ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | local $_ = $self->{ $k }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | CORE::defined( $code->( $k, $self->{ $k } ) ) || CORE::last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 22 | ▶ | sub get { return( $_[0]->{ $_[1] } ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub has { return( shift->exists( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub is_empty { return( scalar( CORE::keys( %{$_[0]} ) ) ? 0 : 1 ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_empty: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | sub json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json: called CC=19 SCAR=31.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 3 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 3 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 3 | ▶ | if( ref( $_[-1] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | $opts = pop( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ▶ | elsif( @_ && !( @_ % 2 ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
@_ and not @_ % 2
MC/DC0%0/2
@_ and not @_ % 2
@_
not @_ % 2
Truth table33%1/3
A and not(B)
A= @_B= not @_ % 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | $opts = { @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 3 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | my $data = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # $opts->{utf8} = 1 if( !CORE::exists( $opts->{utf8} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | ▶ | if( CORE::exists( $opts->{order} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | $opts->{canonical} = CORE::delete( $opts->{order} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | elsif( CORE::exists( $opts->{ordered} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $opts->{canonical} = CORE::delete( $opts->{ordered} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | elsif( CORE::exists( $opts->{sort} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $opts->{canonical} = CORE::delete( $opts->{sort} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | elsif( CORE::exists( $opts->{sorted} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $opts->{canonical} = CORE::delete( $opts->{sorted} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | ▶ | if( !CORE::exists( $opts->{canonical} ) && $opts->{pretty} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $opts->{"canonical"} and $opts->{"pretty"}
MC/DC50%1/2
not exists $opts->{"canonical"} and $opts->{"pretty"}
not exists $opts->{"canonical"}
$opts->{"pretty"}
Truth table66%2/3
not(A) and B
A= not exists $opts->{"canonical"}B= $opts->{"pretty"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | $opts->{canonical} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | ▶ | if( !CORE::exists( $opts->{indent} ) && $opts->{pretty} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $opts->{"indent"} and $opts->{"pretty"}
MC/DC50%1/2
not exists $opts->{"indent"} and $opts->{"pretty"}
not exists $opts->{"indent"}
$opts->{"pretty"}
Truth table66%2/3
not(A) and B
A= not exists $opts->{"indent"}B= $opts->{"pretty"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | $opts->{indent} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | ▶ | if( !CORE::exists( $opts->{relaxed} ) && $opts->{pretty} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $opts->{"relaxed"} and $opts->{"pretty"}
MC/DC50%1/2
not exists $opts->{"relaxed"} and $opts->{"pretty"}
not exists $opts->{"relaxed"}
$opts->{"pretty"}
Truth table66%2/3
not(A) and B
A= not exists $opts->{"relaxed"}B= $opts->{"pretty"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | $opts->{relaxed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | my $j = JSON->new->allow_nonref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | my @keys = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ascii latin1 utf8 pretty indent space_before space_after relaxed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | canonical allow_nonref allow_unknown allow_blessed convert_blessed allow_tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | boolean_values filter_json_object filter_json_single_key_object max_depth max_size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | foreach my $k ( @keys ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 57 | ▶ | next unless( CORE::exists( $opts->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6 | my $code = $j->can( $k ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6 | ▶ | if( defined( $code ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6 | $code->( $j, $opts->{ $k } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | my $json = $j->encode( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | return( Module::Generic::Scalar->new( $json ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # Allow hash keys as object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | sub key_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_object: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $self->_tie_object->key_object( shift( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return( $self->_tie_object->key_object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # $h->keys->sort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | sub keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 5 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 5 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 5 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 5 | ▶ | $obj->enable(1) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | my $rv = Module::Generic::Array->new( [ CORE::keys( %$self ) ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | ▶ | $obj->enable(0) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 5 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 25 | ▶ | sub length { return( Module::Generic::Number->new( CORE::scalar( CORE::keys( %{$_[0]} ) ) ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | sub map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $code = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | return if( ref( $code ) ne 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | return( CORE::map( $code->( $_, $self->{ $_ } ), CORE::keys( %$self ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | sub map_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_array: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $code = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | return if( ref( $code ) ne 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return( Module::Generic::Array->new( [CORE::map( $code->( $_, $self->{ $_ } ), CORE::keys( %$self ) )] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | sub map_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_hash: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $code = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | return if( ref( $code ) ne 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | return( $self->new( {CORE::map( $code->( $_, $self->{ $_ } ), CORE::keys( %$self ) )} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | sub md5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
md5: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | $self->_load_class( 'Digest::MD5' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $data = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my $j = JSON->new->allow_nonref->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $json = eval{ $j->encode( $data ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | return( $self->error( "Unable to serialise the hash reference data to JSON: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $checksum = Digest::MD5::md5_hex( $json ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | return( $checksum ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 8 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 8 | *md5_checksum = \&md5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 8 | *md5_hex = \&md5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | sub merge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 2 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2 | $hash = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | ▶ | return( $self->error( "No valid hash provided." ) ) if( !$hash || ( Scalar::Util::reftype( $hash ) // '' ) ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $hash or (builtin::reftype($hash) // "") ne "HASH"
builtin::reftype($hash) // ""
MC/DC0%0/2
not $hash or (builtin::reftype($hash) // "") ne "HASH"
not $hash
builtin::reftype($hash)
Truth table33%1/3
not(A) or B
A= not $hashB= builtin::reftype($hash)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 2 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | ▶ | $opts = pop( @_ ) if( @_ && ref( $_[-1] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[-1] eq "HASH"
MC/DC50%1/2
@_ and ref $_[-1] eq "HASH"
@_
ref $_[-1] eq "HASH"
Truth table66%2/3
A and B
A= @_B= ref $_[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | ▶ | $opts->{overwrite} = 1 unless( CORE::exists( $opts->{overwrite} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 2 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 2 | my $data = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 2 | my $seen = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | my $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | $copy = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 4 | my $to = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 4 | my $p = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | ▶ | $p = shift( @_ ) if( @_ && ref( $_[-1] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and ref $_[-1] eq "HASH"
MC/DC50%1/2
@_ and ref $_[-1] eq "HASH"
@_
ref $_[-1] eq "HASH"
Truth table66%2/3
A and B
A= @_B= ref $_[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | CORE::foreach my $k ( CORE::keys( %$this ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 14 | ▶ | next if( CORE::exists( $to->{ $k } ) && !$p->{overwrite} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $to->{$k} and not $p->{"overwrite"}
MC/DC100%2/2
exists $to->{$k} and not $p->{"overwrite"}
exists $to->{$k}
not $p->{"overwrite"}
Truth table100%3/3
A and not(B)
A= exists $to->{$k}B= not $p->{"overwrite"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 8 | ▶ | if( ref( $this->{ $k } ) eq 'HASH' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
ref $this->{$k} eq "HASH" or builtin::blessed($this->{$k}) and $this->{$k}->isa("Module::Generic::Hash")
builtin::blessed($this->{$k}) and $this->{$k}->isa("Module::Generic::Hash")
MC/DC33%1/3
ref $this->{$k} eq "HASH" or builtin::blessed($this->{$k}) and $this->{$k}->isa("Module::Generic::Hash")
ref $this->{$k} eq "HASH"
builtin::blessed($this->{$k})
$this->{$k}->isa("Module::Generic::Hash")
Truth table50%2/4
A or B and C
A= ref $this->{$k} eq "HASH"B= builtin::blessed($this->{$k})C= $this->{$k}->isa("Module::Generic::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ( Scalar::Util::blessed( $this->{ $k } ) && $this->{ $k }->isa( 'Module::Generic::Hash' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | my $addr = Scalar::Util::refaddr( $this->{ $k } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 2 | ▶ | if( CORE::exists( $seen->{ $addr } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $to->{ $k } = $seen->{ $addr }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | ▶ | $to->{ $k } = {} unless( CORE::defined( $to->{ $k } ) && ( Scalar::Util::reftype( $to->{ $k } ) // '' ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $to->{$k} and (builtin::reftype($to->{$k}) // "") eq "HASH"
builtin::reftype($to->{$k}) // ""
MC/DC50%1/2
defined $to->{$k} and (builtin::reftype($to->{$k}) // "") eq "HASH"
defined $to->{$k}
builtin::reftype($to->{$k})
Truth table66%2/3
A and B
A= defined $to->{$k}B= builtin::reftype($to->{$k})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | $copy->( $this->{ $k }, $to->{ $k } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | $seen->{ $addr } = $this->{ $k }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 6 | $to->{ $k } = $this->{ $k }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | $copy->( $hash, $data, $opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 2 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 8 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 8 | *message = \&__message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 8 | *message_check = \&_message_check; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 8 | *message_frame = \&_message_frame; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 8 | *message_log = \&_message_log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 8 | *message_log_io = \&_message_log_io; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 8 | *messagef = \&__messagef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | sub noexec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
noexec: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $rv = $self->SUPER::noexec( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | sub pass_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pass_error: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my( @rv, $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if( wantarray ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | @rv = $self->SUPER::pass_error( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return( @rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $rv2 = $self->SUPER::pass_error( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | return( $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | sub remove { return( shift->delete( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub reset { %{$_[0]} = () }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 14 | ▶ | sub set { $_[0]->{ $_[1] } = $_[2]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub size { return( shift->length ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | sub undef { %{$_[0]} = () }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undef: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | sub values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
values: called CC=8 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | ▶ | $code = shift( @_ ) if( @_ && ref( $_[0] ) eq 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and ref $_[0] eq "CODE"
MC/DC0%0/2
@_ and ref $_[0] eq "CODE"
@_
ref $_[0] eq "CODE"
Truth table33%1/3
A and B
A= @_B= ref $_[0] eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | ▶ | $opts = pop( @_ ) if( ( Scalar::Util::reftype( $_[-1] ) // '' ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($_[-1]) // ""
MC/DC0%0/1
builtin::reftype($_[-1]) // ""
builtin::reftype($_[-1])
Truth table50%1/2
A
A= builtin::reftype($_[-1])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | ▶ | if( $code ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | ▶ | if( $opts->{sort} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | return( Module::Generic::Array->new( [ CORE::map( $code->( $_ ), CORE::sort( CORE::values( %$self ) ) ) ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return( Module::Generic::Array->new( [ CORE::map( $code->( $_ ), CORE::values( %$self ) ) ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if( $opts->{sort} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | return( Module::Generic::Array->new( [ CORE::sort( CORE::values( %$self ) ) ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return( Module::Generic::Array->new( [ CORE::values( %$self ) ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | sub _dumper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dumper: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 13 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 13 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 13 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 13 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 13 | my $data = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 13 | my $d = Data::Dumper->new( [ $data ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 13 | $d->Indent(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 13 | $d->Useqq(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 13 | $d->Terse(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 13 | $d->Sortkeys(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # $d->Freezer( '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 13 | $d->Bless( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # return( $d->Dump ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 13 | my $str = $d->Dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 13 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 13 | return( $str ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | sub _internal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_internal: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $meth = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | my $code = $self->can( $meth ) || die( "Method $meth is unknown in class ", ref( $self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->can($meth) || die("Method $meth is unknown in class ", ref $self)
MC/DC0%0/1
$self->can($meth) || die("Method $meth is unknown in class ", ref $self)
$self->can($meth)
Truth table0%0/2
A
A= $self->can($meth)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my( @rv, $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if( wantarray ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | @rv = $code->( $self, $field, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return( @rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $rv2 = $code->( $self, $field, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return( $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | sub __message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__message: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my $rv = $self->SUPER::__message( @_, { skip_frames => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | sub _message_check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message_check: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $rv = $self->SUPER::_message_check( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | sub _message_frame | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message_frame: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $rv = $self->SUPER::_message_frame( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | sub _message_log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message_log: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $rv = $self->SUPER::_message_log( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | sub _message_log_io | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message_log_io: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $rv = $self->SUPER::_message_log_io( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | sub __messagef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__messagef: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $rv = $self->SUPER::__messagef( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | sub _obj_comp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_obj_comp: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 12 | my( $self, $other, $swap, $op ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 12 | my( $lA, $lB ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 12 | $lA = $self->length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 12 | ▶ | if( Scalar::Util::blessed( $other ) && $other->isa( 'Module::Generic::Hash' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($other) and $other->isa("Module::Generic::Hash")
MC/DC50%1/2
builtin::blessed($other) and $other->isa("Module::Generic::Hash")
builtin::blessed($other)
$other->isa("Module::Generic::Hash")
Truth table66%2/3
A and B
A= builtin::blessed($other)B= $other->isa("Module::Generic::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 7 | $lB = $other->length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | elsif( $other =~ /^$NUMBER_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 5 | $lB = $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 12 | ▶ | my $expr = $swap ? "$lB $op $lA" : "$lA $op $lB"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 12 | return( eval( $expr ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | sub _printer { return( shift->printer( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_printer: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | sub _obj_eq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_obj_eq: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 8 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 6 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 6 | my $other = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 6 | my $strA = $self->_dumper( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 6 | my $strB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 6 | ▶ | if( Scalar::Util::blessed( $other ) && $other->isa( 'Module::Generic::Hash' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($other) and $other->isa("Module::Generic::Hash")
MC/DC50%1/2
builtin::blessed($other) and $other->isa("Module::Generic::Hash")
builtin::blessed($other)
$other->isa("Module::Generic::Hash")
Truth table66%2/3
A and B
A= builtin::blessed($other)B= $other->isa("Module::Generic::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | $strB = $other->dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ▶ | elsif( ( Scalar::Util::reftype( $other ) // '' ) eq 'HASH' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($other) // ""
MC/DC0%0/1
builtin::reftype($other) // ""
builtin::reftype($other)
Truth table50%1/2
A
A= builtin::reftype($other)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 4 | $strB = $self->_dumper( $other ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | return(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 6 | return( $strA eq $strB ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | sub _super_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_super_method: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | my $meth = shift( @_ ) || die( "No method to call in our parent." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || die('No method to call in our parent.')
MC/DC0%0/1
shift @_ || die('No method to call in our parent.')
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | my $code = $self->SUPER::can( $meth ) || die( "Method $meth is not supported in our parent class." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->SUPER::can($meth) || die("Method $meth is not supported in our parent class.")
MC/DC0%0/1
$self->SUPER::can($meth) || die("Method $meth is not supported in our parent class.")
$self->SUPER::can($meth)
Truth table0%0/2
A
A= $self->SUPER::can($meth)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my( @rv, $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | if( wantarray ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | @rv = $code->( $self, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | return( @rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $rv2 = $code->( $self, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | return( $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | sub _temporary_disable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_temporary_disable: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | my $cb = shift( @_ ) || die( "No callback provided." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || die('No callback provided.')
MC/DC0%0/1
shift @_ || die('No callback provided.')
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | die( "Callback provided is not a code reference." ) if( ref( $cb // '' ) ne 'CODE' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$cb // ""
MC/DC0%0/1
$cb // ""
$cb
Truth table0%0/2
A
A= $cb
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | $obj->enable(0) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | my( @rv, $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | if( wantarray ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | @rv = $cb->( $self, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | return( @rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | $rv2 = $cb->( $self, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | $obj->enable(1) if( $flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | return( $rv2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | sub _tie_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 34 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tie_object: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 34 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 34 | return( tied( %$self ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 39 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # <https://perldoc.perl.org/perlobj#Destructors> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 39 | CORE::local( $., $@, $!, $^E, $? ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 39 | ▶ | CORE::return if( Module::Generic::_in_global_destruction() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 39 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 39 | ▶ | CORE::return if( !CORE::defined( $self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 39 | ▶ | CORE::untie( %$self ) if( $self && CORE::tied( %$self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self and tied %$self
MC/DC0%0/2
$self and tied %$self
$self
tied %$self
Truth table33%1/3
A and B
A= $selfB= tied %$self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | sub FREEZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FREEZE: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 4 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 4 | ▶ | my $serialiser = CORE::shift( @_ ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ // ""
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 4 | my $class = CORE::ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 4 | my $clone = $self->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 4 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 4 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 4 | ▶ | $obj->enable(1) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | # my %data = %{$clone->{data} // {}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 4 | my %data = %$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 4 | ▶ | $obj->enable(0) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | # Return an array reference rather than a list so this works with Sereal and CBOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # On or before Sereal version 4.023, Sereal did not support multiple values returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 4 | ▶ | if( $serialiser eq 'Sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 2 | require Sereal::Encoder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | require version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 2 | ▶ | if( version->parse( Sereal::Encoder->VERSION ) <= version->parse( '4.023' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | CORE::return( [$class, \%data] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | # But Storable want a list with the first element being the serialised element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 4 | CORE::return( $class, \%data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 2 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 2 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | sub THAW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
THAW: called CC=10 SCAR=27.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 4 | my( $self, undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 4 | ▶ | my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1
ref $args[0] eq "ARRAY"
Truth table33%1/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 4 | ▶ | my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref and ref $ref eq "ARRAY"
ref $self or $self
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref
ref $ref eq "ARRAY"
scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self
$self
Truth table25%1/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
Truth table0%0/3
A or B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 4 | ▶ | my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 4 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | # Storable pattern requires to modify the object it created rather than returning a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 4 | ▶ | if( CORE::ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | foreach( CORE::keys( %$hash ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 4 | $self->{ $_ } = CORE::delete( $hash->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 2 | $new = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | $new = $class->new( $hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 4 | CORE::return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | sub TO_JSON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 1 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 1 | my $ref = { %$self }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | CORE::return( $ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||