TMDB/Collection.pm

filter: Statementstmt 95.3% 41 / 43 Branchbran 40.0% 4 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 5 totaltotal 79.4% 58 / 73 CC 8 SCAR 10.4
CC
8
Cov
84%
_parse_parts
6.3
version
3.1
info
2.1
CRAP 2.8
« TMDB/Genre.pm ↑ Summary TMDB.pm »
1 package TMDB::Collection;
2  
3 #######################
4 # LOAD CORE MODULES
5 #######################
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp qw(croak carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #######################
11 # LOAD CPAN MODULES
12 #######################
13 3 ▶use Object::Tiny qw(id session);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Params::Validate qw(validate_with :types);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 #######################
17 # LOAD DIST MODULES
18 #######################
19 3 ▶use TMDB::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 #######################
22 # VERSION
23 #######################
24 3 our $VERSION = '1.3.0';
25  
26 #######################
27 # PUBLIC METHODS
28 #######################
29  
30 ## ====================
31 ## Constructor
32 ## ====================
33 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
34 1 my $class = shift;
35 1 my %opts = validate_with(
36 params => \@_,
37 spec => {
38 session => {
39 type => OBJECT,
40 isa => 'TMDB::Session',
41 },
42 id => {
43 type => SCALAR,
44 },
45 },
46 );
47  
48 1 my $self = $class->SUPER::new(%opts);
49 1 return $self;
50 } ## end sub new
51  
52 ## ====================
53 ## INFO
54 ## ====================
55 4 ▶sub info {
Subroutine info: called CC=2 SCAR=7.2
Pod undocumented
56 4 my $self = shift;
57 4 ▶ return $self->session->talk(
Branch: 1 branch
BranchTrueFalseTotal
$self->session->lang ? : 4 0 4
58 {
59 method => 'collection/' . $self->id(),
60 params => {
61 language => $self->session->lang
62 ? $self->session->lang
63 : undef,
64 },
65 }
66 );
67 } ## end sub info
68  
69 ## ====================
70 ## VERSION
71 ## ====================
72 1 ▶sub version {
Subroutine version: called CC=3 SCAR=11.3
Pod undocumented
73 1 my ($self) = @_;
74 1 ▶ my $response = $self->session->talk(
Branch: 1 branch
BranchTrueFalseTotal
my $response = $self->session->talk({"method", 'collection/' . $self->id, "want_headers", 1}) or return 1 0 1
75 {
76 method => 'collection/' . $self->id(),
77 want_headers => 1,
78 }
79 ) or return;
80 1 ▶ my $version = $response->{etag} || q();
Condition50%1/2
$response->{'etag'} || ''
l!l
01
MC/DC0%0/1
$response->{'etag'} || ''
$response->{'etag'}
Truth table50%1/2
A
A= $response->{'etag'}
Aresult
11
00
81 1 $version =~ s{"}{}gx;
82 1 return $version;
83 } ## end sub version
84  
85 ## ====================
86 ## INFO HELPERS
87 ## ====================
88  
89 # All titles
90 1 ▶sub titles { return shift->_parse_parts('title'); }
Subroutine titles: called CC=1 SCAR=0.0
Pod undocumented
91  
92 # Title IDs
93 1 ▶sub ids { return shift->_parse_parts('id'); }
Subroutine ids: called CC=1 SCAR=0.0
Pod undocumented
94  
95 #######################
96 # PRIVATE METHODS
97 #######################
98  
99  
100 3 ▶sub _parse_parts {
Subroutine _parse_parts: called CC=5 SCAR=18.4
101 3 my $self = shift;
102 3 my $key = shift;
103 3 my $info = $self->info();
104 3 ▶ my $parts = $info ? $info->{parts} : [];
Branch: 1 branch
BranchTrueFalseTotal
$info ? : 3 0 3
105 3 my @stuff;
106 3 foreach my $part (@$parts) {
107 0 ▶ next unless $part->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $part->{$key} 0 0 0
108 0 push @stuff, $part->{$key};
109 } ## end foreach my $part (@$parts)
110 3 ▶ return @stuff if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 3 3
111 3 return \@stuff;
112 } ## end sub _parse_parts
113  
114 #######################
115 3 1;
« TMDB/Genre.pm ↑ Summary TMDB.pm »