Shutterstock/Image.pm

filter: Statementstmt 81.0% 30 / 37 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 2 / 2 totaltotal 78.8% 41 / 52 CC 3 SCAR 7.8
CC
3
Cov
78%
__ANON__
6.0
__ANON__
2.0
size
2.0
CRAP 2.2
« Shutterstock/Lightbox.pm ↑ Summary Shutterstock/AuthedClient.pm »
1 package WebService::Shutterstock::Image;
2 {
3 14 $WebService::Shutterstock::Image::VERSION = '0.006';
4 }
5  
6 # ABSTRACT: Represent the set of information about a Shutterstock image as returned by the API
7  
8 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 14 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 14 ▶use WebService::Shutterstock::DeferredData qw(deferred);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 14 ▶use WebService::Shutterstock::HasClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 14 with 'WebService::Shutterstock::HasClient';
16  
17  
18 14 has id => ( is => 'ro', required => 1, init_arg => 'image_id' );
19  
20 deferred(
21 qw(
22 categories
23 description
24 enhanced_license_available
25 illustration
26 is_available
27 is_vector
28 keywords
29 model_release
30 r_rated
31 sizes
32 submitter
33 submitter_id
34 vector_type
35 web_url
36 ),
37 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
38 0 my $self = shift;
39 0 my $client = $self->client;
40 0 $client->GET( sprintf( '/images/%s.json', $self->id ) );
41 0 ▶ my $data = $client->process_response(404 => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 return { is_available => 0 };
43 0 });
44 0 ▶ $data->{is_available} = 1 if ! exists $data->{is_available};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $data->{"is_available"} 0 0 0
45 0 return $data;
46 }
47 14 );
48  
49 2 ▶sub size {
Subroutine size: called CC=2 SCAR=6.9
Pod documented
50 2 my $self = shift;
51 2 my $size = shift;
52 2 ▶ return exists($self->sizes->{$size}) ? $self->sizes->{$size} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->sizes->{$size} ? : 1 1 2
53 }
54  
55 1 ▶sub similar {
Subroutine similar: called CC=1 SCAR=0.0
Pod documented
56 1 my $self = shift;
57 1 my $client = $self->client;
58 1 $client->GET(sprintf('/images/%s/similar.json', $self->id));
59 1 my $images = $client->process_response;
60 1 return [ map { $self->new_with_client( 'WebService::Shutterstock::Image', %$_ ) } @$images ];
61 }
62  
63 14 1;
64  
65 __END__
« Shutterstock/Lightbox.pm ↑ Summary Shutterstock/AuthedClient.pm »