blib/lib/TMDB/Collection.pm

filter: Statementstmt 46.5% 20 / 43 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 6 / 12 Podpod 0.0% 0 / 5 totaltotal 35.6% 26 / 73 SCAR 32.0
CC
8
Cov
36%
_parse_parts
30.0
version
12.0
info
6.0
CRAP 24.5
« blib/lib/TMDB/Config.pm ↑ Summary blib/lib/TMDB/Company.pm »
1 package TMDB::Collection;
2  
3 #######################
4 # LOAD CORE MODULES
5 #######################
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp qw(croak carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #######################
11 # LOAD CPAN MODULES
12 #######################
13 1 ▶use Object::Tiny qw(id session);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Params::Validate qw(validate_with :types);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 #######################
17 # LOAD DIST MODULES
18 #######################
19 1 ▶use TMDB::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 #######################
22 # VERSION
23 #######################
24 1 our $VERSION = '1.2.1';
25  
26 #######################
27 # PUBLIC METHODS
28 #######################
29  
30 ## ====================
31 ## Constructor
32 ## ====================
33 sub new {
34 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
35 0 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 0 my $self = $class->SUPER::new(%opts);
49 0 return $self;
50 } ## end sub new
51  
52 ## ====================
53 ## INFO
54 ## ====================
55 sub info {
56 0 ▶ my $self = shift;
Subroutine info: not called CC=2 SCAR=17.9
Pod undocumented
57 0 ▶ return $self->session->talk(
Branch: 1 branch
BranchTrueFalseTotal
$self->session->lang ? : 0 0 0
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 sub version {
73 0 ▶ my ($self) = @_;
Subroutine version: not called CC=3 SCAR=24.8
Pod undocumented
74 0 ▶ my $response = $self->session->talk(
Branch: 1 branch
BranchTrueFalseTotal
my $response = $self->session->talk({"method", 'collection/' . $self->id, "want_headers", 1}) or return 0 0 0
75 {
76 method => 'collection/' . $self->id(),
77 want_headers => 1,
78 }
79 ) or return;
80 0 ▶ my $version = $response->{etag} || q();
Condition0%0/2
$response->{'etag'} || ''
l!l
00
MC/DC0%0/1
$response->{'etag'} || ''
$response->{'etag'}
Truth table0%0/2
A
A= $response->{'etag'}
Aresult
11
00
81 0 $version =~ s{"}{}gx;
82 0 return $version;
83 } ## end sub version
84  
85 ## ====================
86 ## INFO HELPERS
87 ## ====================
88  
89 # All titles
90 0 ▶sub titles { return shift->_parse_parts('title'); }
Subroutine titles: not called CC=1 SCAR=6.9
Pod undocumented
91  
92 # Title IDs
93 0 ▶sub ids { return shift->_parse_parts('id'); }
Subroutine ids: not called CC=1 SCAR=6.9
Pod undocumented
94  
95 #######################
96 # PRIVATE METHODS
97 #######################
98  
99  
100 sub _parse_parts {
101 0 ▶ my $self = shift;
Subroutine _parse_parts: not called CC=5 SCAR=34.0
102 0 my $key = shift;
103 0 my $info = $self->info();
104 0 ▶ my $parts = $info ? $info->{parts} : [];
Branch: 1 branch
BranchTrueFalseTotal
$info ? : 0 0 0
105 0 my @stuff;
106 0 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 0 ▶ return @stuff if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
111 0 return \@stuff;
112 } ## end sub _parse_parts
113  
114 #######################
115 1 1;
« blib/lib/TMDB/Config.pm ↑ Summary blib/lib/TMDB/Company.pm »