Tools/Reflection.pm

filter: Statementstmt 38.8% 26 / 67 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 2 totaltotal 30.0% 34 / 113 CC 12 SCAR 33.1
CC
12
Cov
28%
getMethods
56.0
getMethod
42.0
__ANON__
2.0
CRAP 27.4
↑ Summary Tools/Cameras.pm »
1 package Flickr::Tools::Reflection;
2  
3 1 ▶use Flickr::API::Reflection;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Types::Standard qw ( InstanceOf );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strictures;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with qw(Flickr::Roles::Caching);
12  
13 1 our $VERSION = '1.22';
14  
15 1 extends 'Flickr::Tools';
16  
17 has '+_api_name' => (
18 is => 'ro',
19 1 ▶ isa => sub { $_[0] eq 'Flickr::API::Reflection' },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1 required => 1,
21 default => 'Flickr::API::Reflection',
22 );
23  
24 0 ▶sub getMethods {
Subroutine getMethods: not called CC=7 SCAR=40.3
Pod undocumented
25 0 my ($self, $args) = @_;
26 0 my $methods;
27 0 my $pre_expire = 0;
28  
29 0 $self->_set_cache_hit(1);
30  
31 0 ▶ if ( defined( $args->{clear_cache} ) and $args->{clear_cache} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{"clear_cache"} and $args->{"clear_cache"}) 0 0 0
Condition0%0/3
defined $args->{"clear_cache"} and $args->{"clear_cache"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args->{"clear_cache"} and $args->{"clear_cache"}
defined $args->{"clear_cache"} $args->{"clear_cache"}
Truth table0%0/3
A and B
A= defined $args->{"clear_cache"}B= $args->{"clear_cache"}
ABresult
0X0
100
111
32 0 $pre_expire = 1;
33 }
34  
35 0 ▶ if (defined($args->{list_type}) and $args->{list_type} =~ m/list/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{'list_type'} and $args->{'list_type'} =~ /list/i) { } 0 0 0
Condition0%0/3
defined $args->{"list_type"} and $args->{"list_type"} =~ /list/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args->{"list_type"} and $args->{"list_type"} =~ /list/i
defined $args->{"list_type"} $args->{"list_type"} =~ /list/i
Truth table0%0/3
A and B
A= defined $args->{"list_type"}B= $args->{"list_type"} =~ /list/i
ABresult
0X0
100
111
36  
37 0 $self->_set_cache_key('methods_list');
38  
39 $methods = $self->_cache->get( $self->cache_key,
40 0 ▶ expire_if => sub { $pre_expire } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
41  
42 0 ▶ if ( !defined $methods ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $methods) 0 0 0
43 0 $methods = $self->{_api}->methods_list;
44 0 $self->_set_cache_hit(0);
45 0 $self->_cache->set( $self->cache_key, $methods,
46 $self->cache_duration );
47 }
48 }
49 else {
50  
51 0 $self->_set_cache_key('methods_hash');
52  
53 $methods = $self->_cache->get( $self->cache_key,
54 0 ▶ expire_if => sub { $pre_expire } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 ▶ if ( !defined $methods) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $methods) 0 0 0
56 0 $methods = $self->{_api}->methods_hash;
57 0 $self->_set_cache_hit(0);
58 0 $self->_cache->set( $self->cache_key, $methods,
59 $self->cache_duration );
60 }
61 }
62  
63 0 return $methods;
64 }
65  
66  
67 0 ▶sub getMethod {
Subroutine getMethod: not called CC=6 SCAR=37.4
Pod undocumented
68 0 my ($self, $args) = @_;
69 0 my $rsp = {};
70 0 my $pre_expire = 0;
71  
72 0 $self->_set_cache_hit(1);
73  
74 0 ▶ if ($args =~ m/flickr\.[a-z]+\.*/x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args =~ /flickr\.[a-z]+\.*/x) 0 0 0
75 0 my $tmp = { Method => $args };
76 0 $args = $tmp;
77 }
78 0 ▶ if ( defined( $args->{clear_cache} ) and $args->{clear_cache} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{"clear_cache"} and $args->{"clear_cache"}) 0 0 0
Condition0%0/3
defined $args->{"clear_cache"} and $args->{"clear_cache"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args->{"clear_cache"} and $args->{"clear_cache"}
defined $args->{"clear_cache"} $args->{"clear_cache"}
Truth table0%0/3
A and B
A= defined $args->{"clear_cache"}B= $args->{"clear_cache"}
ABresult
0X0
100
111
79 0 $pre_expire = 1;
80 }
81  
82 0 ▶ if (exists($args->{Method})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{'Method'}) { } 0 0 0
83  
84 0 $self->_set_cache_key( 'Method ' . $args->{Method} );
85  
86 $rsp = $self->_cache->get( $self->cache_key,
87 0 ▶ expire_if => sub { $pre_expire } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 0 ▶ if ( !defined $rsp) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rsp) 0 0 0
89 0 $rsp = $self->{_api}->get_method($args->{Method});
90 0 $self->_set_cache_hit(0);
91 0 $self->_cache->set( $self->cache_key, $rsp,
92 $self->cache_duration );
93 }
94 }
95 else {
96  
97 0 carp 'argument neither a hashref pointing to a method, or the name of a method';
98  
99 }
100 0 return $rsp;
101 }
102  
103  
104 1 1;
105  
106 __END__
↑ Summary Tools/Cameras.pm »