| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Stripe API - ~/lib/Net/API/Stripe/Generic.pm | ||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.101.1 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2020 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2019/11/02 | ||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2024/09/05 | ||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 14 | package Net::API::Stripe::Generic; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 137 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 137 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 137 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 137 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 137 | ▶ | use Module::Generic::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 137 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 137 | ▶ | use Want; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 137 | our( $VERSION ) = 'v0.101.1'; | |||||||||||||||||||||||||||||||||||||||||
| 24 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 137 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 137 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | sub init | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 136 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 136 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | # Get the init params always present and including keys like _parent and _field | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 136 | ▶ | my $init = @_ ? shift( @_ ) : {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 136 | $self->{_parent} = $init->{_parent}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 136 | $self->{_field} = $init->{_field}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 136 | $self->{_error} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 136 | $self->{debug} = $init->{_debug}; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 136 | ▶ | $self->{_dbh} = $init->{_dbh} if( exists( $init->{_dbh} ) && $init->{_dbh} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $init->{"_dbh"} and $init->{"_dbh"}
MC/DC0%0/2
exists $init->{"_dbh"} and $init->{"_dbh"}
exists $init->{"_dbh"}
$init->{"_dbh"}
Truth table33%1/3
A and B
A= exists $init->{"_dbh"}B= $init->{"_dbh"}
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 136 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 40 | # $self->SUPER::init( @_ ) || return; | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 136 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 136 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub field { return( shift->_set_get_scalar( '_field', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub parent { return( shift->_set_get_scalar( '_parent', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | sub TO_JSON | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return( $self->can( 'as_string' ) ? $self->as_string : $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # Used in Net::API::Stripe::Payment::Source and Net::API::Stripe::Connect::ExternalAccount::Card | ||||||||||||||||||||||||||||||||||||||||||
| 56 | sub _address_populate | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_address_populate: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $addr = shift( @_ ) || return; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || (return)
MC/DC0%0/1
shift @_ || (return)
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | # No 'state' property | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $map = | |||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | line1 => 'line1', | ||||||||||||||||||||||||||||||||||||||||||
| 64 | line2 => 'line2', | ||||||||||||||||||||||||||||||||||||||||||
| 65 | city => 'city', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | state => 'state', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | postal_code => 'zip', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | country => 'country', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if( $self->_is_hash( $addr ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | foreach my $k ( keys( %$map ) ) | |||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | next unless( exists( $addr->{ $k } ) && length( $addr->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $addr->{$k} and length $addr->{$k}
MC/DC0%0/2
exists $addr->{$k} and length $addr->{$k}
exists $addr->{$k}
length $addr->{$k}
Truth table0%0/3
A and B
A= exists $addr->{$k}B= length $addr->{$k}
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $sub = "address_" . $map->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->$sub( $addr->{ $k } ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | ▶ | elsif( $self->_is_object( $addr ) && $addr->isa( 'Net::API::Stripe::Address' ) ) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->_is_object($addr) and $addr->isa("Net::API::Stripe::Address")
MC/DC0%0/2
$self->_is_object($addr) and $addr->isa("Net::API::Stripe::Address")
$self->_is_object($addr)
$addr->isa("Net::API::Stripe::Address")
Truth table0%0/3
A and B
A= $self->_is_object($addr)B= $addr->isa("Net::API::Stripe::Address")
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | foreach my $k ( keys( %$map ) ) | |||||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | next unless( exists( $addr->{ $k } ) && length( $addr->{ $k } ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $addr->{$k} and length $addr->{$k}
MC/DC0%0/2
exists $addr->{$k} and length $addr->{$k}
exists $addr->{$k}
length $addr->{$k}
Truth table0%0/3
A and B
A= exists $addr->{$k}B= length $addr->{$k}
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $sub = "address_" . $map->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->$sub( $addr->$k ); | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | else | ||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return( $self->error( "I do not know what to do with '$addr'. I was expecting either a Net::API::Strie::Address or an hash reference." ) ); | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub _convert_measure | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_measure: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $p = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $num = $p->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return if( !length( $num ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | return( $self->error( "No \"from\" parameter was provided to convert number \"$num\"." ) ) if( !length( $p->{from} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $inch_to_cm = 2.54; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $cm_to_inch = 0.39370078740157; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $ounce_to_gram = 28.34952; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $gram_to_ounce = 0.03527396583787; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if( lc( $p->{from} ) eq 'inch' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return( $num / $inch_to_cm ); | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ▶ | elsif( lc( $p->{from} ) eq 'cm' || lc( $p->{from} ) eq 'centimetre' ) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
lc $p->{"from"} eq "cm" or lc $p->{"from"} eq "centimetre"
MC/DC0%0/2
lc $p->{"from"} eq "cm" or lc $p->{"from"} eq "centimetre"
lc $p->{"from"} eq "cm"
lc $p->{"from"} eq "centimetre"
Truth table0%0/3
A or B
A= lc $p->{"from"} eq "cm"B= lc $p->{"from"} eq "centimetre"
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return( $num / $cm_to_inch ); | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | elsif( lc( $p->{from} ) eq 'ounce' ) | ||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return( $num / $ounce_to_gram ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | elsif( lc( $p->{from} ) eq 'gram' ) | ||||||||||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | return( $num / $gram_to_ounce ); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | else | ||||||||||||||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return( $self->error( "I do not know how to convert from \"$p->{from}\"" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | sub _get_base_class | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_base_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $class = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $base = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $base =~ s/\:\:Generic$//; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $pkg = ( $class =~ /^($base\:\:(?:[^\:]+)?)/ )[0]; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | # Overriding Module::Generic | ||||||||||||||||||||||||||||||||||||||||||
| 137 | sub _instantiate_object | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_instantiate_object: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return( $self->{ $field } ) if( exists( $self->{ $field } ) && Scalar::Util::blessed( $self->{ $field } ) && !$self->_is_array( $self->{ $field } ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $self->{$field} and builtin::blessed($self->{$field}) and not $self->_is_array($self->{$field})
exists $self->{$field} and builtin::blessed($self->{$field})
MC/DC0%0/3
exists $self->{$field} and builtin::blessed($self->{$field}) and not $self->_is_array($self->{$field})
exists $self->{$field}
builtin::blessed($self->{$field})
not $self->_is_array($self->{$field})
Truth table0%0/4
A and B and not(C)
A= exists $self->{$field}B= builtin::blessed($self->{$field})C= not $self->_is_array($self->{$field})
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $class = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $this; | |||||||||||||||||||||||||||||||||||||||||
| 144 | my $h = | ||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | '_parent' => $self->{_parent}, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | '_field' => $field, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | '_debug' => $self->{debug}, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $h->{_dbh} = $self->{_dbh} if( $self->{_dbh} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $o; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 153 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||
| 154 | my $rv = eval | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 156 | # https://stackoverflow.com/questions/32608504/how-to-check-if-perl-module-is-available#comment53081298_32608860 | ||||||||||||||||||||||||||||||||||||||||||
| 157 | # my $class_file = join( '/', split( /::/, $class ) ) . '.pm'; | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # if( CORE::exists( $INC{ $class_file } ) || defined( *{"${class}::"} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # if( Class::Load::is_class_loaded( $class ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # if( defined( ${"${class}::VERSION"} ) || scalar( @{"$class::ISA"} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # else | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | # my $rc = eval( "require $class;" ); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $rc = eval{ $self->_load_class( $class ); }; | |||||||||||||||||||||||||||||||||||||||||
| 169 | # print( STDERR __PACKAGE__, "::_instantiate_object(): Error while loading module $class? $@\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | return( $self->error( "Unable to load module $class: $@" ) ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if( $class->isa( 'Module::Generic::Dynamic' ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $o = @_ ? $class->new( @_ ) : $class->new; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $o->{debug} = $self->{debug}; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $o->{_parent} = $self->{_parent}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $o->{_field} = $field; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | else | ||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | $o = @_ ? $class->new( $h, @_ ) : $class->new( $h ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return( $o ); | |||||||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return( $self->error({ code => 500, message => $@ }) ); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | elsif( !defined( $rv ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | return( $self->pass_error ); | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return( $self->pass_error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return( $o ); | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | sub _object_type_to_class | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object_type_to_class: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $type = shift( @_ ) || return( $self->error( "No object type was provided" ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || (return $self->error('No object type was provided'))
MC/DC0%0/1
shift @_ || (return $self->error('No object type was provided'))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | require Net::API::Stripe; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $ref = $Net::API::Stripe::TYPE2CLASS; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return( $self->error( "No object type '$type' known to get its related class for field $self->{_field}" ) ) if( !exists( $ref->{ $type } ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return( $ref->{ $type } ); | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | sub _set_get_hash | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_hash: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $o; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if( @_ || !$self->{ $field } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ or not $self->{$field}
MC/DC0%0/2
@_ or not $self->{$field}
@_
not $self->{$field}
Truth table0%0/3
A or not(B)
A= @_B= not $self->{$field}
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $class = $field; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $class =~ tr/-/_/; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $class =~ s/\_{2,}/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $class = ref( $self ) . '::' . join( '', map( ucfirst( lc( $_ ) ), split( /\_/, $class ) ) ); | |||||||||||||||||||||||||||||||||||||||||
| 217 | # require Devel::StackTrace; | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # my $trace = Devel::StackTrace->new; | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $o = $self->_set_get_hash_as_object( $field, $class, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $o->debug( $self->debug ); | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{ $field } = $o; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $o = $self->{ $field }; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if( want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | return( $o ); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $hash = $o->{_data}; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return( $hash ); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | # Overiden | ||||||||||||||||||||||||||||||||||||||||||
| 233 | sub _set_get_number | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_number: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | @_ = () if( scalar( @_ ) == 1 && !defined( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @_ == 1 and not defined $_[0]
MC/DC0%0/2
scalar @_ == 1 and not defined $_[0]
scalar @_ == 1
not defined $_[0]
Truth table0%0/3
A and not(B)
A= scalar @_ == 1B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->{ $field } = Module::Generic::Number->new( shift( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | sub _set_get_object_array | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_object_array: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $class = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | @_ = () if( scalar( @_ ) == 1 && !defined( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @_ == 1 and not defined $_[0]
MC/DC0%0/2
scalar @_ == 1 and not defined $_[0]
scalar @_ == 1
not defined $_[0]
Truth table0%0/3
A and not(B)
A= scalar @_ == 1B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $ref = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return( $self->error( "I was expecting an array ref, but instead got '$ref'" ) ) if( !$self->_is_array( $ref ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $arr = []; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | for( my $i = 0; $i < scalar( @$ref ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $o = defined( $ref->[$i] ) ? $self->_instantiate_object( $field, $class, $ref->[$i] ) : $self->_instantiate_object( $field, $class ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | return( $self->error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | push( @$arr, $o ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->{ $field } = $arr; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | sub _set_get_object_variant | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_object_variant: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 271 | # The class precisely depends on what we find looking ahead | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # my $class = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||||||||||||
| 275 | my $process = sub | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $ref = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $type = $ref->{object} || return( $self->error( "No object type could be found in hash: ", sub{ $self->_dumper( $ref ) } ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/2
$ref->{'object'} || (return $self->error('No object type could be found in hash: ', sub {
$self->_dumper($ref);
}
))
MC/DC0%0/1
$ref->{'object'} || (return $self->error('No object type could be found in hash: ', sub {
$self->_dumper($ref);
}
))
$ref->{'object'}
Truth table0%0/2
A
A= $ref->{'object'}
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $class = $self->_object_type_to_class( $type ); | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $o = $self->_instantiate_object( $field, $class, $ref ); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $self->{ $field } = $o; | |||||||||||||||||||||||||||||||||||||||||
| 282 | # return( $class->new( %$ref ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 283 | # return( $self->_set_get_object( 'object', $class, $ref ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if( ref( $_[0] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $o = $process->( @_ ) | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # AN array of objects hash | ||||||||||||||||||||||||||||||||||||||||||
| 291 | elsif( ref( $_[0] ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $arr = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $res = []; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | foreach my $data ( @$arr ) | |||||||||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my $o = $process->( $data ) || return( $self->error( "Unable to create object: ", $self->error ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&$process($data) || (return $self->error('Unable to create object: ', $self->error))
MC/DC0%0/1
&$process($data) || (return $self->error('Unable to create object: ', $self->error))
&$process($data)
Truth table0%0/2
A
A= &$process($data)
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | push( @$res, $o ); | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->{ $field } = $res; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | sub _set_get_scalar_or_object_array | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_scalar_or_object_array: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $class = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | @_ = () if( scalar( @_ ) == 1 && !defined( $_[0] ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @_ == 1 and not defined $_[0]
MC/DC0%0/2
scalar @_ == 1 and not defined $_[0]
scalar @_ == 1
not defined $_[0]
Truth table0%0/3
A and not(B)
A= scalar @_ == 1B= not defined $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $ref = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | return( $self->error( "I was expecting an array ref, but instead got '$ref'" ) ) if( !$self->_is_array( $ref ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $arr = []; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | for( my $i = 0; $i < scalar( @$ref ); $i++ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||
| 319 | # If this is an HASH reference, we make it an object | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $o; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if( ref( $ref->[$i] ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $o = $self->_instantiate_object( $field, $class, $ref->[$i] ); | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | else | ||||||||||||||||||||||||||||||||||||||||||
| 326 | { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | # push( @$arr, $ref->[$i] ); | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | $o = defined( $ref->[$i] ) ? $self->_instantiate_object( $field, $class, { id => $ref->[$i] } ) : $self->_instantiate_object( $field, $class ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | return( $self->error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | push( @$arr, $o ); | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->{ $field } = $arr; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | sub _set_get_scalar_or_object_variant | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_scalar_or_object_variant: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if( ref( $_[0] ) eq 'HASH' || ref( $_[0] ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[0] eq "HASH" or ref $_[0] eq "ARRAY"
MC/DC0%0/2
ref $_[0] eq "HASH" or ref $_[0] eq "ARRAY"
ref $_[0] eq "HASH"
ref $_[0] eq "ARRAY"
Truth table0%0/3
A or B
A= ref $_[0] eq "HASH"B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return( $self->_set_get_object_variant( $field, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | else | ||||||||||||||||||||||||||||||||||||||||||
| 349 | { | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return( $self->_set_get_scalar( $field, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if( !$self->{ $field } && want( 'OBJECT' ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->{$field} and want("OBJECT")
MC/DC0%0/2
not $self->{$field} and want("OBJECT")
not $self->{$field}
want("OBJECT")
Truth table0%0/3
not(A) and B
A= not $self->{$field}B= want("OBJECT")
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $null = Module::Generic::Null->new({ debug => $self->{debug}, has_error => 0 }); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | rreturn( $null ); | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | sub _set_get_uri | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_get_uri: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $field = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $str = $self->SUPER::_set_get_uri( $field, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if( defined( $str ) && Scalar::Util::blessed( $str ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $str and builtin::blessed($str)
MC/DC0%0/2
defined $str and builtin::blessed($str)
defined $str
builtin::blessed($str)
Truth table0%0/3
A and B
A= defined $strB= builtin::blessed($str)
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $self->{ $field } = $str->abs( $self->_parent->api_uri ); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub _will { return( shift->SUPER::will( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_will: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 137 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | __END__ | ||||||||||||||||||||||||||||||||||||||||||