| 1 | package TMDB::Genre; | ||||||||||||
| 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 | optional => 1, | ||||||||||||
| 45 | }, | ||||||||||||
| 46 | }, | ||||||||||||
| 47 | ); | ||||||||||||
| 48 | |||||||||||||
| 49 | 1 | my $self = $class->SUPER::new(%opts); | |||||||||||
| 50 | 1 | return $self; | |||||||||||
| 51 | } ## end sub new | ||||||||||||
| 52 | |||||||||||||
| 53 | ## ==================== | ||||||||||||
| 54 | ## LIST | ||||||||||||
| 55 | ## ==================== | ||||||||||||
| 56 | 1 | ▶ | sub list { | ||||||||||
|
Subroutine
list: called CC=5 SCAR=17.0
Pod
undocumented
| |||||||||||||
| 57 | 1 | my ($self) = @_; | |||||||||||
| 58 | 1 | ▶ | my $response = $self->session->talk( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | { | ||||||||||||
| 60 | method => 'genre/list', | ||||||||||||
| 61 | params => { | ||||||||||||
| 62 | language => $self->session->lang | ||||||||||||
| 63 | ? $self->session->lang | ||||||||||||
| 64 | : undef, | ||||||||||||
| 65 | }, | ||||||||||||
| 66 | } | ||||||||||||
| 67 | ); | ||||||||||||
| 68 | 1 | ▶ | return unless $response; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 69 | |||||||||||||
| 70 | 1 | my $genres; | |||||||||||
| 71 | 1 | ▶ | $genres = $response->{genres} || []; | ||||||||||
|
Condition50%1/2
$response->{'genres'} || []
MC/DC0%0/1
$response->{'genres'} || []
$response->{'genres'}
Truth table50%1/2
A
A= $response->{'genres'}
| |||||||||||||
| 72 | 1 | ▶ | return @$genres if wantarray; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 73 | 1 | return $genres; | |||||||||||
| 74 | } ## end sub list | ||||||||||||
| 75 | |||||||||||||
| 76 | ## ==================== | ||||||||||||
| 77 | ## MOVIES | ||||||||||||
| 78 | ## ==================== | ||||||||||||
| 79 | 1 | ▶ | sub movies { | ||||||||||
|
Subroutine
movies: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||
| 80 | 1 | my ( $self, $max_pages ) = @_; | |||||||||||
| 81 | 1 | ▶ | return unless $self->id(); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 82 | 1 | ▶ | return $self->session->paginate_results( | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 83 | { | ||||||||||||
| 84 | method => 'genre/' . $self->id() . '/movies', | ||||||||||||
| 85 | max_pages => $max_pages, | ||||||||||||
| 86 | params => { | ||||||||||||
| 87 | language => $self->session->lang | ||||||||||||
| 88 | ? $self->session->lang | ||||||||||||
| 89 | : undef, | ||||||||||||
| 90 | }, | ||||||||||||
| 91 | } | ||||||||||||
| 92 | ); | ||||||||||||
| 93 | } ## end sub movies | ||||||||||||
| 94 | |||||||||||||
| 95 | ####################### | ||||||||||||
| 96 | 3 | 1; | |||||||||||