Telegram/Generic.pm

filter: Statementstmt 16.9% 70 / 412 Branchbran 0.3% 1 / 300 Conditioncond 0.0% 0 / 90 MC/DCmcdc 0.0% 0 / 46 Subroutinesub 44.9% 22 / 49 Podpod 60.0% 3 / 5 totaltotal 10.6% 96 / 902 SCAR 102.2
CC
190
Cov
9%
_instantiate_object
8882.3
__ANON__
411.8
_set_get_object_array2
182.0
CRAP 27526.1
« Telegram.pm ↑ Summary Telegram/InputFile.pm »
1 # -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Telegram API - ~/lib/Net/API/Telegram/Generic.pm
4 ## Version v0.100.1
5 ## Copyright(c) 2019 Jacques Deguest
6 ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp>
7 ## Created 2019/06/02
8 ## Modified 2020/05/21
9 ##
10 ##----------------------------------------------------------------------------
11 package Net::API::Telegram::Generic;
12 BEGIN
13 {
14 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶ use Devel::StackTrace;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ use DateTime::TimeZone;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶ use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 ## For the JSON::true and JSON::false
24 1 ▶ use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶ use Nice::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶ use Net::API::Telegram::Number;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶ our( $VERSION ) = 'v0.100.1';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 };
29  
30 sub init
31 {
32 0 ▶ my $self = shift( @_ );
Subroutine init: not called CC=5 SCAR=34.0
Pod documented
33 ## Get the init params always present and including keys like _parent and _field
34 0 my $init = shift( @_ );
35 0 my $class = ref( $self );
36 0 ▶ if( Scalar::Util::blessed( $init ) )
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($init)) { } 0 0 0
37 {
38 0 ▶ if( $init->isa( 'Net::API::Telegram' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($init->isa("Net::API::Telegram")) 0 0 0
39 {
40 0 $self->{ '_parent' } = $init;
41 0 $self->{ '_debug' } = $init->debug;
42 }
43 }
44 else
45 {
46 0 ▶ $self->{_parent} = $init->{ '_parent' } || warn( "Property '_parent' is not provided in the init hash!\n" );
Condition0%0/2
$init->{'_parent'} || warn("Property '_parent' is not provided in the init hash!\n")
l!l
00
MC/DC0%0/1
$init->{'_parent'} || warn("Property '_parent' is not provided in the init hash!\n")
$init->{'_parent'}
Truth table0%0/2
A
A= $init->{'_parent'}
Aresult
11
00
47 0 ▶ $self->{_field} = $init->{ '_field' } || warn( "Property '_field' is not provided in the init hash!\n" );
Condition0%0/2
$init->{'_field'} || warn("Property '_field' is not provided in the init hash!\n")
l!l
00
MC/DC0%0/1
$init->{'_field'} || warn("Property '_field' is not provided in the init hash!\n")
$init->{'_field'}
Truth table0%0/2
A
A= $init->{'_field'}
Aresult
11
00
48 0 $self->{debug} = $init->{ '_debug' };
49 }
50 0 $self->{_init_strict_use_sub} = 1;
51 0 $self->SUPER::init( @_ );
52 0 return( $self );
53 }
54  
55 sub as_hash
56 {
57 0 ▶ my $self = shift( @_ );
Subroutine as_hash: not called CC=8 SCAR=42.8
Pod documented
58 0 ▶ my $class = ref( $self ) || return( $self->error( "This method \"as_hash\" must be called with an object, not using class \"$self\"." ) );
Condition0%0/2
ref $self || (return $self->error(qq[This method "as_hash" must be called with an object, not using class "$self".]))
l!l
00
MC/DC0%0/1
ref $self || (return $self->error(qq[This method "as_hash" must be called with an object, not using class "$self".]))
ref $self
Truth table0%0/2
A
A= ref $self
Aresult
11
00
59 0 ▶ my $anti_loop = shift( @_ ) || '_as_hash_anti_loop_' . time();
Condition0%0/2
shift @_ || '_as_hash_anti_loop_' . time
l!l
00
MC/DC0%0/1
shift @_ || '_as_hash_anti_loop_' . time
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
60 0 my $hash = {};
61 local $crawl = sub
62 {
63 0 ▶ my $this = shift( @_ );
Subroutine __ANON__: not called CC=12 SCAR=50.5
64 0 ▶ if( Scalar::Util::blessed( $this ) )
Branch: 3 branches
BranchTrueFalseTotal
if (builtin::blessed($this)) { } 0 0 0
elsif (ref $this eq 'ARRAY') { } 0 0 0
elsif (ref $this eq 'HASH') { } 0 0 0
65 {
66 ## $self->_message( 3, "\tvalue to check '$this' is an object of type '", ref( $this ), "'." );
67 #my $ref = $self->{ $k }->as_hash( $anti_loop );
68 #return( $ref );
69 0 ▶ if( $this->can( 'as_hash' ) )
Branch: 3 branches
BranchTrueFalseTotal
if ($this->can('as_hash')) { } 0 0 0
elsif (overload::Overloaded($this)) { } 0 0 0
elsif ($this->can('as_string')) { } 0 0 0
70 {
71 ## $self->_message( 3, "\t\tobject can 'as_hash'" );
72 0 my $h = $this->as_hash( $anti_loop );
73 ## $self->_message( 3, "\t\tobject '", ref( $this ), "' returned value is: ", sub{ $self->dumper( $h ) } );
74 0 ▶ return( $h ) if( length( $h ) );
Branch: 1 branch
BranchTrueFalseTotal
if length $h 0 0 0
75 }
76 elsif( overload::Overloaded( $this ) )
77 {
78 0 return( "$o" );
79 }
80 elsif( $this->can( 'as_string' ) )
81 {
82 0 return( $this->as_string );
83 }
84 else
85 {
86 0 warn( "Warning only: I have an object of class \"", ref( $this ), "\" ($this), but is not overloaded and does not have an as_string method, so I don't know what to do to get a string version of it.\n" );
87 }
88 }
89 elsif( ref( $this ) eq 'ARRAY' )
90 {
91 ## $self->_message( 3, "\tvalue to check '$this' is an array reference." );
92 0 my $arr = [];
93 0 foreach my $that ( @$this )
94 {
95 0 my $v = $crawl->( $that );
96 ## $self->_message( 3, "\t\tReturned value to add to array is '$v': ", sub{ $self->dumper( $v ) } );
97 0 ▶ push( @$arr, $v ) if( length( $v ) );
Branch: 1 branch
BranchTrueFalseTotal
if length $v 0 0 0
98 }
99 ## $self->_messagef( 3, "\treturning %d items in this array.", scalar( @$arr ) );
100 0 return( $arr );
101 }
102 elsif( ref( $this ) eq 'HASH' )
103 {
104 ## $self->_message( 3, "\tvalue to check '$this' is a hash reference." );
105 0 ▶ return( $this ) if( exists( $this->{ $anti_loop } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $this->{$anti_loop} 0 0 0
106 0 $this->{ $anti_loop }++;
107 0 my $ref = {};
108 0 foreach my $k ( keys( %$this ) )
109 {
110 0 $ref->{ $k } = $crawl->( $this->{ $k } );
111 }
112 0 return( $ref );
113 }
114 else
115 {
116 ## $self->_message( 3, "\tvalue to check '$this' is a scalar, returning it." );
117 0 return( $this );
118 }
119 0 };
120
121 0 foreach my $k ( keys( %$self ) )
122 {
123 0 ▶ last if( exists( $self->{ $anti_loop } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{$anti_loop} 0 0 0
124 ## Only process keys if their corresponding method exists in their package
125 0 ▶ if( defined( &{ "${class}::${k}" } ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined &{"${class}::$k";}) 0 0 0
126 {
127 ## $self->_message( 3, "Getting data for $k" );
128 0 ▶ if( $self->_is_boolean( $k ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_boolean($k)) { } 0 0 0
129 {
130 0 ▶ $hash->{ $k } = ( $self->{ $k } ? JSON::true : JSON::false );
Branch: 1 branch
BranchTrueFalseTotal
$self->{$k} ? : 0 0 0
131 ## $self->_message( 3, "\tvalue set to boolean '$hash->{$k}'" );
132 }
133 else
134 {
135 0 $hash->{ $k } = $crawl->( $self->{ $k } );
136 }
137 }
138 }
139 0 return( $hash );
140 }
141  
142 sub dumpto
143 {
144 0 ▶ my $self = shift( @_ );
Subroutine dumpto: not called CC=2 SCAR=17.9
Pod documented
145 0 my( $data, $file ) = @_;
146 0 local $Data::Dumper::Sortkeys = 1;
147 0 local $Data::Dumper::Terse = 1;
148 0 local $Data::Dumper::Indent = 1;
149 0 local $Data::Dumper::Useqq = 1;
150 0 ▶ my $fh = IO::File->new( ">$file" ) || die( "Unable to create file '$file': $!\n" );
Condition0%0/2
'IO::File'->new(">$file") || die("Unable to create file '${file}': $!\n")
l!l
00
MC/DC0%0/1
'IO::File'->new(">$file") || die("Unable to create file '${file}': $!\n")
'IO::File'->new(">$file")
Truth table0%0/2
A
A= 'IO::File'->new(">$file")
Aresult
11
00
151 0 $fh->print( Data::Dumper::Dumper( $data ), "\n" );
152 0 $fh->close;
153 ## 606 so it can work under command line and web alike
154 0 chmod( 0666, $file );
155 0 return( 1 );
156 }
157  
158 0 ▶sub parent { return( shift->{_parent} ); }
Subroutine parent: not called CC=1 SCAR=6.9
Pod undocumented
159  
160 sub TO_JSON
161 {
162 0 ▶ my $self = shift( @_ );
Subroutine TO_JSON: not called CC=2 SCAR=17.9
Pod undocumented
163 0 ▶ return( $self->can( 'as_string' ) ? $self->as_string : $self );
Branch: 1 branch
BranchTrueFalseTotal
$self->can('as_string') ? : 0 0 0
164 }
165  
166 sub _download
167 {
168 0 ▶ my $self = shift( @_ );
Subroutine _download: not called CC=10 SCAR=47.0
169 0 ▶ my $id = shift( @_ ) || return( $self->error( "No file id was provided" ) );
Condition0%0/2
shift @_ || (return $self->error('No file id was provided'))
l!l
00
MC/DC0%0/1
shift @_ || (return $self->error('No file id was provided'))
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
170 0 my $opts = {};
171 0 ▶ $opts = shift( @_ ) if( ref( $_[0] ) eq 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "HASH" 0 0 0
172 0 my $parent = $self->_parent;
173 ## https://core.telegram.org/bots/api#getfile
174 0 ▶ my $file = $self->_parent->getFile({
Condition0%0/2
$self->_parent->getFile({'file_id', $id}) || (return $self->error("Unable to get file information object for file id ${id}: ", $parent->error->message))
l!l
00
MC/DC0%0/1
$self->_parent->getFile({'file_id', $id}) || (return $self->error("Unable to get file information object for file id ${id}: ", $parent->error->message))
$self->_parent->getFile({'file_id', $id})
Truth table0%0/2
A
A= $self->_parent->getFile({'file_id', $id})
Aresult
11
00
175 'file_id' => $id
176 }) || return( $self->error( "Unable to get file information object for file id $id: ", $parent->error->message ) );
177 0 my $path = $file->file_path;
178 0 my $uri = URI->new( $parent->dl_uri );
179 0 $uri->path( $uri->path . '/' . $path );
180 0 my $datadir = File::Spec->tmpdir;
181 0 my $tmpdir = File::Temp::tempdir( 'telegram-file-XXXXXXX', DIR => $datadir, CLEANUP => $parent->cleanup_temp );
182 ##( $fh, $file ) = tempfile( "data-XXXXXXX", SUFFIX => ".${ext}", DIR => $tmpdir );
183 0 my $filepath = File::Temp::mktemp( "$tmpdir/data-XXXXXXX" );
184 0 ▶ $filepath .= '.' . $opts->{ext} if( $opts->{ext} );
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"ext"} 0 0 0
185 0 my $req = JDev::HTTP::Request->new( 'GET' => $uri );
186 0 my $res = $parent->agent->request( $req, $filepath );
187 0 my $mime = $res->content_type;
188 0 my $len = $res->content_length;
189 0 ▶ if( !$self->is_success )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_success) 0 0 0
190 {
191 0 return( $self->error( sprintf( "Unable to download file \"$path\". Server returned error code %s (%s)", $res->code, $res->message ) ) );
192 }
193 0 ▶ if( $len != -s( $filepath ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($len != -s $filepath) 0 0 0
194 {
195 0 warn( sprintf( "Warning only: The size in bytes returned by the server ($len) is different than the local file (%d)\n", -s( $filepath ) ) );
196 }
197 0 my $ext;
198 0 ▶ if( !$opts->{ext} && length( $mime ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"ext"} and length $mime) 0 0 0
Condition0%0/3
not $opts->{"ext"} and length $mime
!ll&&!rl&&r
000
MC/DC0%0/2
not $opts->{"ext"} and length $mime
not $opts->{"ext"} length $mime
Truth table0%0/3
not(A) and B
A= not $opts->{"ext"}B= length $mime
ABresult
0X0
100
111
199 {
200 0 ▶ if( $mime =~ /\/([^\/]+)$/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($mime =~ m[/([^/]+)$]) 0 0 0
201 {
202 0 my $ext = $1;
203 0 rename( $filepath, "${filepath}.${ext}" );
204 0 $filepath = "${filepath}.${ext}";
205 }
206 }
207 return({
208 0 'filepath' => $filepath,
209 'mime' => $mime,
210 'response' => $res,
211 'size' => -s( $filepath ),
212 });
213 }
214  
215 0 ▶sub _field { return( shift->_set_get( '_field', @_ ) ); }
Subroutine _field: not called CC=1 SCAR=6.9
216  
217 sub _get_base_class
218 {
219 0 ▶ my $self = shift( @_ );
Subroutine _get_base_class: not called CC=1 SCAR=6.9
220 0 my $class = shift( @_ );
221 0 my $base = __PACKAGE__;
222 0 $base =~ s/\:\:Generic$//;
223 0 my $pkg = ( $class =~ /^($base\:\:(?:[^\:]+)?)/ )[0];
224 }
225  
226 # sub _instantiate_object
227 # {
228 # my $self = shift( @_ );
229 # my $field = shift( @_ );
230 # my $class = shift( @_ );
231 # my $h =
232 # {
233 # '_parent' => $self->{ '_parent' },
234 # '_field' => $field,
235 # '_debug' => $self->{ '_debug' },
236 # };
237 # $h->{ '_dbh' } = $self->{ '_dbh' } if( $self->{ '_dbh' } );
238 # $self->{_parent}->_load( [ $class ] ) || return( $self->error( $self->{_parent}->error->message ) );
239 # my $o = @_ ? $class->new( $h, @_ ) : $class->new( $h );
240 # return( $self->error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) );
241 # return( $o );
242 # }
243  
244 sub _instantiate_object
245 {
246 0 ▶ my $self = shift( @_ );
Subroutine _instantiate_object: not called CC=99 SCAR=90.9
247 0 my $name = shift( @_ );
248 0 ▶ return( $self->{ $name } ) if( exists( $self->{ $name } ) && Scalar::Util::blessed( $self->{ $name } ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{$name} and builtin::blessed($self->{$name}) 0 0 0
Condition0%0/3
exists $self->{$name} and builtin::blessed($self->{$name})
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{$name} and builtin::blessed($self->{$name})
exists $self->{$name} builtin::blessed($self->{$name})
Truth table0%0/3
A and B
A= exists $self->{$name}B= builtin::blessed($self->{$name})
ABresult
0X0
100
111
249 0 my $class = shift( @_ );
250 # print( STDERR __PACKAGE__, "::_instantiate_object() called for name '$name' and class '$class'\n" );
251 # $self->message( 3, "called for name '$name' and class '$class'." );
252 0 my $this;
253 my $h =
254 {
255 '_parent' => $self->{_parent},
256 '_field' => $name,
257 '_debug' => $self->{debug},
258 0 };
259 0 ▶ $h->{_dbh} = $self->{_dbh} if( $self->{_dbh} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_dbh"} 0 0 0
260 0 my $o;
261 0 ▶ try
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 3 branches
BranchTrueFalseTotal
unless defined $Nice::Try::NEED_TO_RETURN 0 0 0
if ($INC{"threads.pm"} and not exists $INC{"forks.pm"}) 0 0 0
wantarray ? : 0 0 0
Condition0%0/3
$INC{"threads.pm"} and not exists $INC{"forks.pm"}
!ll&&!rl&&r
000
MC/DC0%0/2
$INC{"threads.pm"} and not exists $INC{"forks.pm"}
$INC{"threads.pm"} not exists $INC{"forks.pm"}
Truth table0%0/3
A and not(B)
A= $INC{"threads.pm"}B= not exists $INC{"forks.pm"}
ABresult
0X0
100
111
262 0 ▶ {
Subroutine __ANON__: not called CC=21 SCAR=60.2
263 ## https://stackoverflow.com/questions/32608504/how-to-check-if-perl-module-is-available#comment53081298_32608860
264 0 ▶ eval( "require $class;" ) unless( defined( *{"${class}::"} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined *{"${class}::";} 0 0 0
265 # print( STDERR __PACKAGE__, "::_instantiate_object(): Error while loading module $class? $@\n" );
266 # $self->message( 3, "Error while loading module $class? $@" );
267 0 ▶ return( $self->error( "Unable to load module $class: $@" ) ) if( $@ );
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
268 0 ▶ $o = @_ ? $class->new( $h, @_ ) : $class->new( $h );
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
269 0 ▶ return( $self->pass_error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $o 0 0 0
270 }
271 1 ▶ catch( $e )
Subroutine BEGIN: called CC=1 SCAR=6.3
Subroutine BEGIN: called CC=1 SCAR=6.3
Subroutine __ANON__: not called CC=1 SCAR=6.3
Branch: 34 branches
BranchTrueFalseTotal
if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { } 0 0 0
if ($Nice::Try::WANT eq 'OBJECT') { } 0 0 0
elsif ($Nice::Try::WANT eq 'CODE') { } 0 0 0
elsif ($Nice::Try::WANT eq 'HASH') { } 0 0 0
elsif ($Nice::Try::WANT eq 'ARRAY') { } 0 0 0
elsif ($Nice::Try::WANT eq 'REFSCALAR') { } 0 0 0
elsif ($Nice::Try::WANT eq 'GLOB') { } 0 0 0
elsif ($Nice::Try::WANT eq 'LIST') { } 0 0 0
elsif ($Nice::Try::WANT eq 'BOOLEAN') { } 0 0 0
elsif ($Nice::Try::WANT eq 'VOID') { } 0 0 0
elsif ($Nice::Try::WANT eq 'SCALAR') { } 0 0 0
&$Nice::Try::TRY ? : 0 0 0
if scalar @Nice::Try::VOID 0 0 0
if ($Nice::Try::WANTARRAY) { } 0 0 0
elsif (defined $Nice::Try::WANTARRAY) { } 0 0 0
if defined $Nice::Try::LAST_VAL 0 0 0
length $@ ? : 0 0 0
unless builtin::blessed($@) 0 0 0
if ($Nice::Try::DIED) 0 0 0
if ($Nice::Try::HAS_CATCH) 0 0 0
if not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL 0 0 0
if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { } 0 0 0
if ($Nice::Try::WANT eq 'OBJECT') { } 0 0 0
elsif ($Nice::Try::WANT eq 'CODE') { } 0 0 0
elsif ($Nice::Try::WANT eq 'HASH') { } 0 0 0
elsif ($Nice::Try::WANT eq 'ARRAY') { } 0 0 0
elsif ($Nice::Try::WANT eq 'REFSCALAR') { } 0 0 0
elsif ($Nice::Try::WANT eq 'GLOB') { } 0 0 0
elsif ($Nice::Try::WANT eq 'LIST') { } 0 0 0
elsif ($Nice::Try::WANT eq 'BOOLEAN') { } 0 0 0
elsif ($Nice::Try::WANT eq 'VOID') { } 0 0 0
elsif ($Nice::Try::WANT eq 'SCALAR') { } 0 0 0
if ($Nice::Try::WANTARRAY) { } 0 0 0
elsif (defined $Nice::Try::WANTARRAY) { } 0 0 0
Condition0%0/8
defined $Nice::Try::WANT and length $Nice::Try::WANT
!ll&&!rl&&r
000
not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
!ll
00
defined $Nice::Try::WANT and length $Nice::Try::WANT
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Nice::Try::WANT and length $Nice::Try::WANT
defined $Nice::Try::WANT length $Nice::Try::WANT
MC/DC0%0/1
not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
not defined $Nice::Try::WANTARRAY
MC/DC0%0/2
defined $Nice::Try::WANT and length $Nice::Try::WANT
defined $Nice::Try::WANT length $Nice::Try::WANT
Truth table0%0/3
A and B
A= defined $Nice::Try::WANTB= length $Nice::Try::WANT
ABresult
0X0
100
111
Truth table0%0/2
not(A)
A= not defined $Nice::Try::WANTARRAY
Aresult
00
11
Truth table0%0/3
A and B
A= defined $Nice::Try::WANTB= length $Nice::Try::WANT
ABresult
0X0
100
111
272 0 ▶ {
Subroutine __ANON__: not called CC=3 SCAR=24.0
273 # print( STDERR __PACKAGE__, "::_instantiate_object() An error occured while loading module $class for name '$name': $e\n" );
274 0 return( $self->error({ code => 500, message => $e }) );
275 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=6.3
Subroutine BEGIN: called CC=1 SCAR=6.3
Subroutine BEGIN: called CC=1 SCAR=6.3
Branch: 56 branches
BranchTrueFalseTotal
if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { } 0 0 0
if ($Nice::Try::WANT eq 'OBJECT') { } 0 0 0
elsif ($Nice::Try::WANT eq 'CODE') { } 0 0 0
elsif ($Nice::Try::WANT eq 'HASH') { } 0 0 0
elsif ($Nice::Try::WANT eq 'ARRAY') { } 0 0 0
elsif ($Nice::Try::WANT eq 'REFSCALAR') { } 0 0 0
elsif ($Nice::Try::WANT eq 'GLOB') { } 0 0 0
elsif ($Nice::Try::WANT eq 'LIST') { } 0 0 0
elsif ($Nice::Try::WANT eq 'BOOLEAN') { } 0 0 0
elsif ($Nice::Try::WANT eq 'VOID') { } 0 0 0
elsif ($Nice::Try::WANT eq 'SCALAR') { } 0 0 0
&$Nice::Try::CATCH ? : 0 0 0
if scalar @Nice::Try::VOID 0 0 0
if ($Nice::Try::WANTARRAY) { } 0 0 0
elsif (defined $Nice::Try::WANTARRAY) { } 0 0 0
if $@ 0 0 0
if (defined $Nice::Try::CATCH_DIED) 0 0 0
if (defined $Nice::Try::WANTARRAY || defined $Nice::Try::BREAK && $Nice::Try::BREAK eq 'return' and !builtin::blessed($Nice::Try::RETVAL[0]) || builtin::blessed($Nice::Try::RETVAL[0]) && !$Nice::Try::RETVAL[0]->isa('Nice::Try::SENTINEL')) { } 0 0 0
elsif (scalar @Nice::Try::VOID and !builtin::blessed($Nice::Try::VOID[0]) || builtin::blessed($Nice::Try::VOID[0]) && !$Nice::Try::VOID[0]->isa('Nice::Try::SENTINEL')) { } 0 0 0
if defined $Nice::Try::BREAK and $Nice::Try::BREAK eq "return" 0 0 0
if (not defined $Nice::Try::BREAK or $Nice::Try::BREAK eq "return") 0 0 0
if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { } 0 0 0
if ($Nice::Try::WANT eq 'LIST') { } 0 0 0
elsif ($Nice::Try::WANT eq 'VOID') { } 0 0 0
elsif ($Nice::Try::WANT eq 'OBJECT') { } 0 0 0
elsif ($Nice::Try::WANT eq 'REFSCALAR') { } 0 0 0
elsif ($Nice::Try::WANT eq 'SCALAR') { } 0 0 0
elsif ($Nice::Try::WANT eq 'BOOLEAN') { } 0 0 0
elsif ($Nice::Try::WANT eq 'CODE') { } 0 0 0
elsif ($Nice::Try::WANT eq 'HASH') { } 0 0 0
elsif ($Nice::Try::WANT eq 'ARRAY') { } 0 0 0
elsif ($Nice::Try::WANT eq 'GLOB') { } 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
if (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__NEXT__') { } 0 0 0
elsif (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__LAST__') { } 0 0 0
elsif (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__REDO__') { } 0 0 0
elsif (defined $Nice::Try::BREAK and $Nice::Try::BREAK eq 'return') { } 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::NEED_TO_RETURN ? : 0 0 0
$Nice::Try::WANTARRAY ? : 0 0 0
$Nice::Try::WANTARRAY ? : 0 0 0
scalar @Nice::Try::VOID > 1 ? : 0 0 0
if (defined $Nice::Try::BREAK) 0 0 0
if ($Nice::Try::BREAK eq 'next') { } 0 0 0
elsif ($Nice::Try::BREAK eq 'last') { } 0 0 0
elsif ($Nice::Try::BREAK eq 'redo') { } 0 0 0
scalar @Nice::Try::LAST_VAL > 1 ? : 0 0 0
if not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL 0 0 0
Condition0%0/50
defined $Nice::Try::WANT and length $Nice::Try::WANT
!ll&&!rl&&r
000
defined $Nice::Try::WANTARRAY || defined $Nice::Try::BREAK && $Nice::Try::BREAK eq "return" and !builtin::blessed($Nice::Try::RETVAL[0]) || builtin::blessed($Nice::Try::RETVAL[0]) && !$Nice::Try::RETVAL[0]->isa("Nice::Try::SENTINEL")
!ll&&!rl&&r
000
defined $Nice::Try::WANTARRAY or defined $Nice::Try::BREAK and $Nice::Try::BREAK eq "return"
l!l&&r!l&&!r
000
defined $Nice::Try::BREAK and $Nice::Try::BREAK eq "return"
!ll&&!rl&&r
000
not builtin::blessed($Nice::Try::RETVAL[0]) or builtin::blessed($Nice::Try::RETVAL[0]) and not $Nice::Try::RETVAL[0]->isa("Nice::Try::SENTINEL")
l!l&&r!l&&!r
000
builtin::blessed($Nice::Try::RETVAL[0]) and not $Nice::Try::RETVAL[0]->isa("Nice::Try::SENTINEL")
!ll&&!rl&&r
000
defined $Nice::Try::BREAK and $Nice::Try::BREAK eq "return"
!ll&&!rl&&r
000
not defined $Nice::Try::BREAK or $Nice::Try::BREAK eq "return"
l!l&&r!l&&!r
000
defined $Nice::Try::WANT and length $Nice::Try::WANT
!ll&&!rl&&r
000
defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq "__NEXT__"
!ll&&!rl&&r
000
defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq "__LAST__"
!ll&&!rl&&r
000
defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq "__REDO__"
!ll&&!rl&&r
000
defined $Nice::Try::BREAK and $Nice::Try::BREAK eq "return"
!ll&&!rl&&r
000
scalar @Nice::Try::VOID and !builtin::blessed($Nice::Try::VOID[0]) || builtin::blessed($Nice::Try::VOID[0]) && !$Nice::Try::VOID[0]->isa("Nice::Try::SENTINEL")
!ll&&!rl&&r
000
not builtin::blessed($Nice::Try::VOID[0]) or builtin::blessed($Nice::Try::VOID[0]) and not $Nice::Try::VOID[0]->isa("Nice::Try::SENTINEL")
l!l&&r!l&&!r
000
builtin::blessed($Nice::Try::VOID[0]) and not $Nice::Try::VOID[0]->isa("Nice::Try::SENTINEL")
!ll&&!rl&&r
000
not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
!ll
00
MC/DC0%0/2
defined $Nice::Try::WANT and length $Nice::Try::WANT
defined $Nice::Try::WANT length $Nice::Try::WANT
MC/DC0%0/6
defined $Nice::Try::WANTARRAY || defined $Nice::Try::BREAK && $Nice::Try::BREAK eq "return" and !builtin::blessed($Nice::Try::RETVAL[0]) || builtin::blessed($Nice::Try::RETVAL[0]) && !$Nice::Try::RETVAL[0]->isa("Nice::Try::SENTINEL")
defined $Nice::Try::WANTARRAY defined $Nice::Try::BREAK $Nice::Try::BREAK eq "return" not builtin::blessed($Nice::Try::RETVAL[0]) builtin::blessed($Nice::Try::RETVAL[0]) not $Nice::Try::RETVAL[0]->isa("Nice::Try::SENTINEL")
MC/DC0%0/2
not defined $Nice::Try::BREAK or $Nice::Try::BREAK eq "return"
not defined $Nice::Try::BREAK $Nice::Try::BREAK eq "return"
MC/DC0%0/2
defined $Nice::Try::WANT and length $Nice::Try::WANT
defined $Nice::Try::WANT length $Nice::Try::WANT
MC/DC0%0/2
defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq "__NEXT__"
defined $Nice::Try::RETVAL[0] $Nice::Try::RETVAL[0] eq "__NEXT__"
MC/DC0%0/2
defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq "__LAST__"
defined $Nice::Try::RETVAL[0] $Nice::Try::RETVAL[0] eq "__LAST__"
MC/DC0%0/2
defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq "__REDO__"
defined $Nice::Try::RETVAL[0] $Nice::Try::RETVAL[0] eq "__REDO__"
MC/DC0%0/4
scalar @Nice::Try::VOID and !builtin::blessed($Nice::Try::VOID[0]) || builtin::blessed($Nice::Try::VOID[0]) && !$Nice::Try::VOID[0]->isa("Nice::Try::SENTINEL")
scalar @Nice::Try::VOID not builtin::blessed($Nice::Try::VOID[0]) builtin::blessed($Nice::Try::VOID[0]) not $Nice::Try::VOID[0]->isa("Nice::Try::SENTINEL")
MC/DC0%0/1
not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
not defined $Nice::Try::WANTARRAY
Truth table0%0/3
A and B
A= defined $Nice::Try::WANTB= length $Nice::Try::WANT
ABresult
0X0
100
111
Truth table0%0/10
A or B and C and not(D) or E and not(F)
A= defined $Nice::Try::WANTARRAYB= defined $Nice::Try::BREAKC= $Nice::Try::BREAK eq "return"D= not builtin::blessed($Nice::Try::RETVAL[0])E= builtin::blessed($Nice::Try::RETVAL[0])F= not $Nice::Try::RETVAL[0]->isa("Nice::Try::SENTINEL")
ABCDEFresult
00XXXX0
010XXX0
1XX00X0
1XX0100
01100X0
0110100
1XX1XX1
1XX0111
0111XX1
0110111
Truth table0%0/3
not(A) or B
A= not defined $Nice::Try::BREAKB= $Nice::Try::BREAK eq "return"
ABresult
1X1
011
000
Truth table0%0/3
A and B
A= defined $Nice::Try::WANTB= length $Nice::Try::WANT
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $Nice::Try::RETVAL[0]B= $Nice::Try::RETVAL[0] eq "__NEXT__"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $Nice::Try::RETVAL[0]B= $Nice::Try::RETVAL[0] eq "__LAST__"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $Nice::Try::RETVAL[0]B= $Nice::Try::RETVAL[0] eq "__REDO__"
ABresult
0X0
100
111
Truth table0%0/5
A and not(B) or C and not(D)
A= scalar @Nice::Try::VOIDB= not builtin::blessed($Nice::Try::VOID[0])C= builtin::blessed($Nice::Try::VOID[0])D= not $Nice::Try::VOID[0]->isa("Nice::Try::SENTINEL")
ABCDresult
0XXX0
100X0
10100
11XX1
10111
Truth table0%0/2
not(A)
A= not defined $Nice::Try::WANTARRAY
Aresult
00
11
276 # $self->message( 3, "Returning newly generated object $o with structure: ", $self->dumper( $o ) );
277 0 return( $o );
278 }
279  
280 0 ▶sub _is_boolean { return( 0 ); }
Subroutine _is_boolean: not called CC=1 SCAR=6.9
281  
282 0 ▶sub _message { return( shift->SUPER::message( @_ ) ); }
Subroutine _message: not called CC=1 SCAR=6.9
283  
284 0 ▶sub _messagef { return( shift->SUPER::messagef( @_ ) ); }
Subroutine _messagef: not called CC=1 SCAR=6.9
285  
286 sub _object_type_to_class
287 {
288 0 ▶ my $self = shift( @_ );
Subroutine _object_type_to_class: not called CC=3 SCAR=24.8
289 0 ▶ my $type = shift( @_ ) || return( $self->error( "No object type was provided" ) );
Condition0%0/2
shift @_ || (return $self->error('No object type was provided'))
l!l
00
MC/DC0%0/1
shift @_ || (return $self->error('No object type was provided'))
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
290 0 my $ref = $Net::API::Telegram::TYPE2CLASS;
291 0 $self->_messagef( 3, "\$TYPE2CLASS has %d elements", scalar( keys( %$ref ) ) );
292 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
BranchTrueFalseTotal
unless exists $ref->{$type} 0 0 0
293 0 return( $ref->{ $type } );
294 }
295  
296 0 ▶sub _parent { return( shift->_set_get( '_parent', @_ ) ); }
Subroutine _parent: not called CC=1 SCAR=6.9
297  
298 sub _set_get_hash
299 {
300 0 ▶ my $self = shift( @_ );
Subroutine _set_get_hash: not called CC=1 SCAR=6.9
301 0 my $field = shift( @_ );
302 0 my $class = $field;
303 0 $class =~ tr/-/_/;
304 0 $class =~ s/\_{2,}/_/g;
305 0 $class = join( '', map( ucfirst( lc( $_ ) ), split( /\_/, $class ) ) );
306 0 return( $self->_set_get_hash_as_object( $field, $class, @_ ) );
307 }
308  
309 sub _set_get_number
310 {
311 0 ▶ my $self = shift( @_ );
Subroutine _set_get_number: not called CC=2 SCAR=17.9
312 0 my $field = shift( @_ );
313 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
314 {
315 0 $self->{ $field } = Net::API::Telegram::Number->new( shift( @_ ) );
316 }
317 0 return( $self->{ $field } );
318 }
319  
320 sub _set_get_number_or_object
321 {
322 0 ▶ my $self = shift( @_ );
Subroutine _set_get_number_or_object: not called CC=4 SCAR=30.0
323 0 my $field = shift( @_ );
324 0 my $class = shift( @_ );
325 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
326 {
327 0 ▶ if( ref( $_[0] ) eq 'HASH' || Scalar::Util::blessed( $_[0] ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH' or builtin::blessed($_[0])) { } 0 0 0
Condition0%0/3
ref $_[0] eq "HASH" or builtin::blessed($_[0])
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] eq "HASH" or builtin::blessed($_[0])
ref $_[0] eq "HASH" builtin::blessed($_[0])
Truth table0%0/3
A or B
A= ref $_[0] eq "HASH"B= builtin::blessed($_[0])
ABresult
1X1
011
000
328 {
329 0 return( $self->_set_get_object( $field, $class, @_ ) );
330 }
331 else
332 {
333 0 return( $self->_set_get_number( $field, @_ ) );
334 }
335 }
336 0 return( $self->{ $field } );
337 }
338  
339 sub _set_get_object_array2
340 {
341 0 ▶ my $self = shift( @_ );
Subroutine _set_get_object_array2: not called CC=13 SCAR=52.0
342 0 my $field = shift( @_ );
343 0 my $class = shift( @_ );
344 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
345 {
346 0 my $this = shift( @_ );
347 0 ▶ return( $self->error( "I was expecting an array ref, but instead got '$this'" ) ) if( ref( $this ) ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $this ne "ARRAY" 0 0 0
348 0 my $arr1 = [];
349 0 foreach my $ref ( @$this )
350 {
351 0 ▶ return( $self->error( "I was expecting an embeded array ref, but instead got '$ref'." ) ) if( ref( $ref ) ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref ne "ARRAY" 0 0 0
352 0 my $arr = [];
353 0 ▶ for( my $i = 0; $i < scalar( @$ref ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$ref) 0 0 0
354 {
355 0 my $o;
356 0 ▶ if( defined( $ref->[$i] ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ref->[$i]) { } 0 0 0
357 {
358 0 ▶ return( $self->error( "Parameter provided for adding object of class $class is not a reference." ) ) if( !ref( $ref->[$i] ) );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ref->[$i] 0 0 0
359 0 ▶ if( Scalar::Util::blessed( $ref->[$i] ) )
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($ref->[$i])) { } 0 0 0
elsif (ref $ref->[$i] eq 'HASH') { } 0 0 0
360 {
361 0 my $pack = $ref->[$i]->isa( $class );
362 0 ▶ if( $pack )
Branch: 1 branch
BranchTrueFalseTotal
if ($pack) { } 0 0 0
363 {
364 0 $o->{_parent} = $self->{_parent};
365 0 $o->{_debug} = $self->{_debug};
366 0 ▶ $o->{_dbh} = $self->{_dbh} if( $self->{_dbh} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_dbh"} 0 0 0
367 0 $o = $ref->[$i];
368 }
369 else
370 {
371 0 return( $self->error( "Object provided ($pack) is not a $class object" ) );
372 }
373 }
374 elsif( ref( $ref->[$i] ) eq 'HASH' )
375 {
376 0 $o = $self->_instantiate_object( $field, $class, $ref->[$i] );
377 }
378 else
379 {
380 0 $self->error( "Warning only: data provided to instaantiate object of class $class is not a hash reference" );
381 }
382 }
383 else
384 {
385 0 $o = $self->_instantiate_object( $field, $class );
386 }
387 0 ▶ return( $self->error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 0 0
388 0 push( @$arr, $o );
389 }
390 0 push( @$arr1, $arr );
391 }
392 0 $self->{ $field } = $arr1;
393 }
394 0 return( $self->{ $field } );
395 }
396  
397 sub _set_get_object_array
398 {
399 0 ▶ my $self = shift( @_ );
Subroutine _set_get_object_array: not called CC=11 SCAR=48.8
400 0 my $field = shift( @_ );
401 0 my $class = shift( @_ );
402 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
403 {
404 0 my $ref = shift( @_ );
405 0 ▶ return( $self->error( "I was expecting an array ref, but instead got '$ref'" ) ) if( ref( $ref ) ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref ne "ARRAY" 0 0 0
406 0 my $arr = [];
407 0 ▶ for( my $i = 0; $i < scalar( @$ref ); $i++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$ref) 0 0 0
408 {
409 0 $self->_message( 3, "Calling method $class->$field with value '", $ref->[$i], "'" );
410 ## Either the value provided is not defined, and we just instantiate an empty object, or
411 ## the value is a hash and we instantiate a new object with those parameters, or
412 ## we have been provided an existing object
413 ## my $o = defined( $ref->[$i] ) ? $class->new( $h, $ref->[$i] ) : $class->new( $h );
414 0 my $o;
415 0 ▶ if( defined( $ref->[$i] ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ref->[$i]) { } 0 0 0
416 {
417 0 ▶ return( $self->error( "Parameter provided for adding object of class $class is not a reference." ) ) if( !ref( $ref->[$i] ) );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ref->[$i] 0 0 0
418 0 ▶ if( Scalar::Util::blessed( $ref->[$i] ) )
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($ref->[$i])) { } 0 0 0
elsif (ref $ref->[$i] eq 'HASH') { } 0 0 0
419 {
420 0 my $pack = $ref->[$i]->isa( $class );
421 0 ▶ if( $pack )
Branch: 1 branch
BranchTrueFalseTotal
if ($pack) { } 0 0 0
422 {
423 0 $o->{_parent} = $self->{_parent};
424 0 $o->{_debug} = $self->{debug};
425 0 ▶ $o->{_dbh} = $self->{_dbh} if( $self->{_dbh} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_dbh"} 0 0 0
426 0 $o = $ref->[$i];
427 }
428 else
429 {
430 0 return( $self->error( "Object provided ($pack) is not a $class object" ) );
431 }
432 }
433 elsif( ref( $ref->[$i] ) eq 'HASH' )
434 {
435 #$o = $class->new( $h, $ref->[$i] );
436 0 $o = $self->_instantiate_object( $field, $class, $ref->[$i] );
437 }
438 else
439 {
440 0 $self->error( "Warning only: data provided to instaantiate object of class $class is not a hash reference" );
441 }
442 }
443 else
444 {
445 0 $o = $self->_instantiate_object( $field, $class );
446 }
447 0 ▶ return( $self->error( "Unable to instantiate an object of class $class: ", $class->error ) ) if( !defined( $o ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $o 0 0 0
448 0 push( @$arr, $o );
449 }
450 0 $self->{ $field } = $arr;
451 }
452 0 return( $self->{ $field } );
453 }
454  
455 sub _set_get_object_variant
456 {
457 0 ▶ my $self = shift( @_ );
Subroutine _set_get_object_variant: not called CC=6 SCAR=37.4
458 0 my $field = shift( @_ );
459 ## The class precisely depends on what we find looking ahead
460 ## my $class = shift( @_ );
461 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
462 {
463 local $process = sub
464 {
465 0 ▶ my $ref = shift( @_ );
Subroutine __ANON__: not called CC=2 SCAR=17.9
466 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 {
l!l
00
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'}
Aresult
11
00
467 0 my $class = $self->_object_type_to_class( $type );
468 0 $self->_message( 3, "Object type $type has class $class" );
469 0 my $o = $self->_instantiate_object( $field, $class, $ref );
470 0 $self->{ $field } = $o;
471 ## return( $class->new( %$ref ) );
472 ## return( $self->_set_get_object( 'object', $class, $ref ) );
473 0 };
474
475 0 ▶ if( ref( $_[0] ) eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
elsif (ref $_[0] eq 'ARRAY') { } 0 0 0
476 {
477 0 my $o = $process->( @_ )
478 }
479 ## AN array of objects hash
480 elsif( ref( $_[0] ) eq 'ARRAY' )
481 {
482 0 my $arr = shift( @_ );
483 0 my $res = [];
484 0 foreach my $data ( @$arr )
485 {
486 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))
l!l
00
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)
Aresult
11
00
487 0 push( @$res, $o );
488 }
489 0 $self->{ $field } = $res;
490 }
491 }
492 0 return( $self->{ $field } );
493 }
494  
495 1 1;
496  
497 __END__
498 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
« Telegram.pm ↑ Summary Telegram/InputFile.pm »