Tools/Cameras.pm

filter: Statementstmt 40.6% 26 / 64 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 61.5% 8 / 13 Podpod 100% 2 / 2 totaltotal 33.3% 36 / 108 CC 11 SCAR 31.9
CC
11
Cov
30%
getBrands
56.0
getBrandModels
30.0
__ANON__
2.0
CRAP 24.2
« Tools/Reflection.pm ↑ Summary Tools.pm »
1 package Flickr::Tools::Cameras;
2  
3 2 ▶use Flickr::API::Cameras;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Types::Standard qw ( InstanceOf );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strictures;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 with qw(Flickr::Roles::Caching);
12  
13 2 our $VERSION = '1.22';
14  
15 2 extends 'Flickr::Tools';
16  
17 has '+_api_name' => (
18 is => 'ro',
19 1 ▶ isa => sub { $_[0] eq 'Flickr::API::Cameras' },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 2 required => 1,
21 default => 'Flickr::API::Cameras',
22 );
23  
24 0 ▶sub getBrands {
Subroutine getBrands: not called CC=7 SCAR=40.3
Pod documented
25 0 my ( $self, $args ) = @_;
26 0 my $brands;
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('brands_list');
38  
39 $brands = $self->_cache->get( $self->cache_key,
40 0 ▶ expire_if => sub { $pre_expire } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 ▶ if ( !defined $brands ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $brands) 0 0 0
42 0 $brands = $self->{_api}->brands_list;
43 0 $self->_set_cache_hit(0);
44 0 $self->_cache->set( $self->cache_key, $brands,
45 $self->cache_duration );
46 }
47 }
48 else {
49  
50 0 $self->_set_cache_key('brands_hash');
51  
52 $brands = $self->_cache->get( $self->cache_key,
53 0 ▶ expire_if => sub { $pre_expire } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 ▶ if ( !defined $brands ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $brands) 0 0 0
55 0 $brands = $self->{_api}->brands_hash;
56 0 $self->_set_cache_hit(0);
57 0 $self->_cache->set( $self->cache_key, $brands,
58 $self->cache_duration );
59 }
60 }
61 0 return $brands;
62 }
63  
64 0 ▶sub getBrandModels {
Subroutine getBrandModels: not called CC=5 SCAR=34.0
Pod documented
65 0 my ( $self, $args ) = @_;
66 0 my $models = {};
67 0 my $pre_expire = 0;
68  
69 0 $self->_set_cache_hit(1);
70  
71 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
72 0 $pre_expire = 1;
73 }
74  
75 0 ▶ if ( exists( $args->{Brand} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{'Brand'}) { } 0 0 0
76  
77 0 $self->_set_cache_key( 'Models ' . $args->{Brand} );
78  
79 $models = $self->_cache->get( $self->cache_key,
80 0 ▶ expire_if => sub { $pre_expire } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
81 0 ▶ if ( !defined $models ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $models) 0 0 0
82 0 $models = $self->{_api}->get_cameras( $args->{Brand} );
83 0 $self->_set_cache_hit(0);
84 0 $self->_cache->set( $self->cache_key, $models,
85 $self->cache_duration );
86 }
87 }
88 else {
89  
90 0 carp
91 "\nCannot return models unless a required argument: Brand is passed in\n";
92  
93 }
94  
95 0 return $models;
96  
97 }
98  
99 2 1;
100  
101 __END__
« Tools/Reflection.pm ↑ Summary Tools.pm »