blib/lib/WWW/TheMovieDB/Search.pm

filter: Statementstmt 18.6% 25 / 134 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 77 MC/DCmcdc 0.0% 0 / 45 Subroutinesub 24.0% 6 / 25 Podpod 100% 19 / 19 totaltotal 14.8% 50 / 336 CC 50 SCAR 65.6
CC
50
Cov
10%
Movie_browse
1406.0
new
6.0
Movie_getImages
6.0
CRAP 705.3
↑ Summary
1 package WWW::TheMovieDB::Search;
2  
3 1 ▶use 5.008009;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Switch;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 require Exporter;
11  
12 1 our @ISA = qw(Exporter);
13  
14 # Items to export into callers namespace by default. Note: do not export
15 # names by default without a very good reason. Use EXPORT_OK instead.
16 # Do not simply export all your public functions/methods/constants.
17  
18 # This allows declaration use WWW::TheMovieDB::Search ':all';
19 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
20 # will save memory.
21 1 our %EXPORT_TAGS = ( 'all' => [ qw(
22 Movie_getInfo
23 Movie_browse
24 Movie_getImages
25 Movie_getLatest
26 Movie_getTranslations
27 Movie_getVersion
28 Movie_imdbLookup
29 Movie_search
30 Person_getInfo
31 Person_getLatest
32 Person_getVersion
33 Person_search
34 Genres_getList
35 ) ] );
36  
37 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
38  
39 1 our @EXPORT = qw();
40  
41 1 our $VERSION = '0.04';
42  
43  
44 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
45 0 my $package = shift;
46
47 0 $package::key = '';
48 0 $package::lang = 'en';
49 0 $package::ver = '2.1';
50 0 $package::type = 'xml';
51 0 $package::uri = 'http://api.themoviedb.org';
52
53 0 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 0 0 0
54 0 $package->key($_[0]);
55 }
56
57 0 return bless({}, $package);
58 }
59  
60 0 ▶sub lang {
Subroutine lang: not called CC=1 SCAR=6.9
Pod documented
61 0 my $package = shift;
62 0 $package::lang = shift;
63 0 return;
64 }
65  
66 0 ▶sub ver {
Subroutine ver: not called CC=1 SCAR=6.9
Pod documented
67 0 my $package = shift;
68 0 $pacakge::ver = shift;
69 0 return;
70 }
71  
72 0 ▶sub key {
Subroutine key: not called CC=1 SCAR=6.9
Pod documented
73 0 my $package = shift;
74 0 $package::key = shift;
75 0 return;
76 }
77  
78 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
79 0 my $package = shift;
80 0 $package::type = shift;
81 0 return;
82 }
83  
84 0 ▶sub buildURL {
Subroutine buildURL: not called CC=1 SCAR=6.9
Pod documented
85 0 my ($package,$method) = @_;
86
87 0 my $url = $package::uri ."/". $package::ver ."/". $method ."/". $package::lang ."/". $package::type ."/". $package::key;
88
89 0 return $url;
90 }
91  
92 0 ▶sub Movie_browse {
Subroutine Movie_browse: not called CC=37 SCAR=72.5
Pod documented
93 0 my ($package,%data) = @_;
94
95
96 0 my $url = $package->buildURL("Movie.browse");
97 0 $url .= "?";
98
99 0 ▶ unless ((exists $data{'order'} && $data{'order'} =~ m/^(asc|desc)$/) && (exists $data{'order_by'} && $data{'order_by'} =~ m/^(rating|release|title)$/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $data{"order"} and $data{"order"} =~ /^(asc|desc)$/ and (exists $data{"order_by"} and $data{"order_by"} =~ /^(rating|release|title)$/)) 0 0 0
Condition0%0/9
exists $data{"order"} and $data{"order"} =~ /^(asc|desc)$/ and (exists $data{"order_by"} and $data{"order_by"} =~ /^(rating|release|title)$/)
!ll&&!rl&&r
000
exists $data{"order"} and $data{"order"} =~ /^(asc|desc)$/
!ll&&!rl&&r
000
exists $data{"order_by"} and $data{"order_by"} =~ /^(rating|release|title)$/
!ll&&!rl&&r
000
MC/DC0%0/4
exists $data{"order"} and $data{"order"} =~ /^(asc|desc)$/ and (exists $data{"order_by"} and $data{"order_by"} =~ /^(rating|release|title)$/)
exists $data{"order"} $data{"order"} =~ /^(asc|desc)$/ exists $data{"order_by"} $data{"order_by"} =~ /^(rating|release|title)$/
Truth table0%0/5
A and B and C and D
A= exists $data{"order"}B= $data{"order"} =~ /^(asc|desc)$/C= exists $data{"order_by"}D= $data{"order_by"} =~ /^(rating|release|title)$/
ABCDresult
0XXX0
10XX0
110X0
11100
11111
100 0 return "Missing order and/or order_by.";
101 }
102
103 0 foreach my $key (sort keys %data) {
104 0 ▶ $url .= '&order='. $data{'order'} if ($key eq 'order');
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "order" 0 0 0
105 0 ▶ $url .= '&order_by='. $data{'order_by'} if ($key eq 'order_by');
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "order_by" 0 0 0
106
107 0 ▶ $url .= '&certifications='. $data{'certifications'} if ($key eq 'certifications' && $data{'certifications'} ne "");
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "certifications" and $data{"certifications"} ne "" 0 0 0
Condition0%0/3
$key eq "certifications" and $data{"certifications"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "certifications" and $data{"certifications"} ne ""
$key eq "certifications" $data{"certifications"} ne ""
Truth table0%0/3
A and B
A= $key eq "certifications"B= $data{"certifications"} ne ""
ABresult
0X0
100
111
108 0 ▶ $url .= '&companies='. $data{'companies'} if ($key eq 'companies' && $data{'companies'} =~ m/(\d+,)*\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "companies" and $data{"companies"} =~ /(\d+,)*\d+$/ 0 0 0
Condition0%0/3
$key eq "companies" and $data{"companies"} =~ /(\d+,)*\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "companies" and $data{"companies"} =~ /(\d+,)*\d+$/
$key eq "companies" $data{"companies"} =~ /(\d+,)*\d+$/
Truth table0%0/3
A and B
A= $key eq "companies"B= $data{"companies"} =~ /(\d+,)*\d+$/
ABresult
0X0
100
111
109 0 ▶ $url .= '&countries='. $data{'countries'} if ($key eq 'countries' && $data{'countries'} ne "");
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "countries" and $data{"countries"} ne "" 0 0 0
Condition0%0/3
$key eq "countries" and $data{"countries"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "countries" and $data{"countries"} ne ""
$key eq "countries" $data{"countries"} ne ""
Truth table0%0/3
A and B
A= $key eq "countries"B= $data{"countries"} ne ""
ABresult
0X0
100
111
110 0 ▶ $url .= '&genres='. $data{'genres'} if ($key eq 'genres' && $data{'genres'} =~ m/(\d+,)*\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "genres" and $data{"genres"} =~ /(\d+,)*\d+$/ 0 0 0
Condition0%0/3
$key eq "genres" and $data{"genres"} =~ /(\d+,)*\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "genres" and $data{"genres"} =~ /(\d+,)*\d+$/
$key eq "genres" $data{"genres"} =~ /(\d+,)*\d+$/
Truth table0%0/3
A and B
A= $key eq "genres"B= $data{"genres"} =~ /(\d+,)*\d+$/
ABresult
0X0
100
111
111 0 ▶ $url .= '&genres_selector='. $data{'genres_selector'} if ($key eq 'genres_selector' && $data{'genres_selector'} =~ m/^(and|or)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "genres_selector" and $data{"genres_selector"} =~ /^(and|or)$/ 0 0 0
Condition0%0/3
$key eq "genres_selector" and $data{"genres_selector"} =~ /^(and|or)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "genres_selector" and $data{"genres_selector"} =~ /^(and|or)$/
$key eq "genres_selector" $data{"genres_selector"} =~ /^(and|or)$/
Truth table0%0/3
A and B
A= $key eq "genres_selector"B= $data{"genres_selector"} =~ /^(and|or)$/
ABresult
0X0
100
111
112 0 ▶ $url .= '&min_votes='. $data{'min_votes'} if ($key eq 'min_votes' && $data{'min_votes'} =~ m/^(\d+)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "min_votes" and $data{"min_votes"} =~ /^(\d+)$/ 0 0 0
Condition0%0/3
$key eq "min_votes" and $data{"min_votes"} =~ /^(\d+)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "min_votes" and $data{"min_votes"} =~ /^(\d+)$/
$key eq "min_votes" $data{"min_votes"} =~ /^(\d+)$/
Truth table0%0/3
A and B
A= $key eq "min_votes"B= $data{"min_votes"} =~ /^(\d+)$/
ABresult
0X0
100
111
113 0 ▶ $url .= '&page='. $data{'page'} if ($key eq 'page' && $data{'page'} =~ m/^\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "page" and $data{"page"} =~ /^\d+$/ 0 0 0
Condition0%0/3
$key eq "page" and $data{"page"} =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "page" and $data{"page"} =~ /^\d+$/
$key eq "page" $data{"page"} =~ /^\d+$/
Truth table0%0/3
A and B
A= $key eq "page"B= $data{"page"} =~ /^\d+$/
ABresult
0X0
100
111
114 0 ▶ $url .= '&per_page='. $data{'per_page'} if ($key eq 'per_page' && $data{'per_page'} =~ m/^\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "per_page" and $data{"per_page"} =~ /^\d+$/ 0 0 0
Condition0%0/3
$key eq "per_page" and $data{"per_page"} =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "per_page" and $data{"per_page"} =~ /^\d+$/
$key eq "per_page" $data{"per_page"} =~ /^\d+$/
Truth table0%0/3
A and B
A= $key eq "per_page"B= $data{"per_page"} =~ /^\d+$/
ABresult
0X0
100
111
115 0 ▶ $url .= '&query='. uri_escape($data{'query'}) if ($key eq 'query' && $data{'query'} ne "");
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "query" and $data{"query"} ne "" 0 0 0
Condition0%0/3
$key eq "query" and $data{"query"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "query" and $data{"query"} ne ""
$key eq "query" $data{"query"} ne ""
Truth table0%0/3
A and B
A= $key eq "query"B= $data{"query"} ne ""
ABresult
0X0
100
111
116 0 ▶ $url .= '&rating_max='. $data{'rating_max'} if ($key eq 'rating_max' && $data{'rating_max'} =~ m/^\d*\.{0,1}\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "rating_max" and $data{"rating_max"} =~ /^\d*\.{0,1}\d+$/ 0 0 0
Condition0%0/3
$key eq "rating_max" and $data{"rating_max"} =~ /^\d*\.{0,1}\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "rating_max" and $data{"rating_max"} =~ /^\d*\.{0,1}\d+$/
$key eq "rating_max" $data{"rating_max"} =~ /^\d*\.{0,1}\d+$/
Truth table0%0/3
A and B
A= $key eq "rating_max"B= $data{"rating_max"} =~ /^\d*\.{0,1}\d+$/
ABresult
0X0
100
111
117 0 ▶ $url .= '&rating_min='. $data{'rating_min'} if ($key eq 'rating_min' && $data{'rating_min'} =~ m/^\d*\.{0,1}\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "rating_min" and $data{"rating_min"} =~ /^\d*\.{0,1}\d+$/ 0 0 0
Condition0%0/3
$key eq "rating_min" and $data{"rating_min"} =~ /^\d*\.{0,1}\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "rating_min" and $data{"rating_min"} =~ /^\d*\.{0,1}\d+$/
$key eq "rating_min" $data{"rating_min"} =~ /^\d*\.{0,1}\d+$/
Truth table0%0/3
A and B
A= $key eq "rating_min"B= $data{"rating_min"} =~ /^\d*\.{0,1}\d+$/
ABresult
0X0
100
111
118 0 ▶ $url .= '&release_max='. $data{'release_max'} if ($key eq 'release_max' && $data{'release_max'} =~ m/^-{0,1}\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "release_max" and $data{"release_max"} =~ /^-{0,1}\d+$/ 0 0 0
Condition0%0/3
$key eq "release_max" and $data{"release_max"} =~ /^-{0,1}\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "release_max" and $data{"release_max"} =~ /^-{0,1}\d+$/
$key eq "release_max" $data{"release_max"} =~ /^-{0,1}\d+$/
Truth table0%0/3
A and B
A= $key eq "release_max"B= $data{"release_max"} =~ /^-{0,1}\d+$/
ABresult
0X0
100
111
119 0 ▶ $url .= '&release_min='. $data{'release_min'} if ($key eq 'release_min' && $data{'release_min'} =~ m/^-{0,1}\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "release_min" and $data{"release_min"} =~ /^-{0,1}\d+$/ 0 0 0
Condition0%0/3
$key eq "release_min" and $data{"release_min"} =~ /^-{0,1}\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "release_min" and $data{"release_min"} =~ /^-{0,1}\d+$/
$key eq "release_min" $data{"release_min"} =~ /^-{0,1}\d+$/
Truth table0%0/3
A and B
A= $key eq "release_min"B= $data{"release_min"} =~ /^-{0,1}\d+$/
ABresult
0X0
100
111
120 0 ▶ $url .= '&year='. $data{'year'} if ($key eq 'year' && $data{'year'} =~ m/^\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "year" and $data{"year"} =~ /^\d+$/ 0 0 0
Condition0%0/3
$key eq "year" and $data{"year"} =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$key eq "year" and $data{"year"} =~ /^\d+$/
$key eq "year" $data{"year"} =~ /^\d+$/
Truth table0%0/3
A and B
A= $key eq "year"B= $data{"year"} =~ /^\d+$/
ABresult
0X0
100
111
121 }
122
123
124 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
125 0 return $content;
126 }
127  
128 0 ▶sub Movie_getImages {
Subroutine Movie_getImages: not called CC=2 SCAR=17.9
Pod documented
129 0 my ($package,$movieid) = @_;
130  
131 0 my $url = $package->buildURL("Movie.getImages");
132 0 $url .= "/". $movieid;
133 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
134 0 return $content;
135 }
136  
137 0 ▶sub Movie_getInfo {
Subroutine Movie_getInfo: not called CC=2 SCAR=17.9
Pod documented
138 0 my ($package,$movieid) = @_;
139
140 0 my $url = $package->buildURL("Movie.getInfo");
141 0 $url .= "/". $movieid;
142 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
143
144 0 return $content;
145 }
146  
147 0 ▶sub Movie_getLatest {
Subroutine Movie_getLatest: not called CC=2 SCAR=17.9
Pod documented
148 0 my $package = shift;
149
150 0 my $url = $package->buildURL("Movie.getLatest");
151  
152 0 print $url;
153 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
154
155 0 return $content;
156 }
157  
158 0 ▶sub Movie_getTranslations {
Subroutine Movie_getTranslations: not called CC=2 SCAR=17.9
Pod documented
159 0 my ($package,$movieid) = @_;
160
161 0 my $url = $package->buildURL("Movie.getTranslations");
162 0 $url .= "/". $movieid;
163 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
164
165 0 return $content;
166 }
167  
168 0 ▶sub Movie_getVersion {
Subroutine Movie_getVersion: not called CC=2 SCAR=17.9
Pod documented
169 0 my ($package,$movieid) = @_;
170
171 0 my $url = $package->buildURL("Movie.getVersion");
172 0 $url .= "/". $movieid;
173 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
174
175 0 return $content;
176 }
177  
178 0 ▶sub Movie_imdbLookup {
Subroutine Movie_imdbLookup: not called CC=2 SCAR=17.9
Pod documented
179 0 my ($package,$imdbid) = @_;
180
181 0 my $url = $package->buildURL("Movie.imdbLookup");
182 0 $url .= "/". $imdbid;
183 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
184
185 0 return $content;
186 }
187  
188 0 ▶sub Movie_search {
Subroutine Movie_search: not called CC=2 SCAR=17.9
Pod documented
189 0 my ($package,$query) = @_;
190 0 $query = uri_escape($query);
191
192 0 my $url = $package->buildURL("Movie.search");
193 0 $url .= "/". $query;
194
195 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
196
197 0 return $content;
198 }
199  
200 0 ▶sub Person_getInfo {
Subroutine Person_getInfo: not called CC=2 SCAR=17.9
Pod documented
201 0 my ($package,$personid) = @_;
202
203 0 my $url = $package->buildURL("Person.getInfo");
204 0 $url .= "/". $personid;
205
206 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
207
208 0 return $content;
209 }
210  
211 0 ▶sub Person_getLatest {
Subroutine Person_getLatest: not called CC=2 SCAR=17.9
Pod documented
212 0 my $package = shift;
213
214 0 my $url = $package->buildURL("Person.getLatest");
215  
216 0 print $url;
217 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
218
219 0 return $content;
220
221 }
222  
223 0 ▶sub Person_getVersion {
Subroutine Person_getVersion: not called CC=2 SCAR=17.9
Pod documented
224 0 my ($package,$personid) = @_;
225
226 0 my $url = $package->buildURL("Person.getInfo");
227 0 $url .= "/". $personid;
228
229 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
230
231 0 return $content;
232 }
233  
234 0 ▶sub Person_search {
Subroutine Person_search: not called CC=2 SCAR=17.9
Pod documented
235 0 my ($package,$query) = @_;
236 0 $query = uri_escape($query);
237
238 0 my $url = $package->buildURL("Person.search");
239 0 $url .= "/". $query;
240
241 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
242
243 0 return $content;
244 }
245  
246 0 ▶sub Genres_getList {
Subroutine Genres_getList: not called CC=2 SCAR=17.9
Pod documented
247 0 my $package = shift;
248
249 0 my $url = $package->buildURL("Genres.getList");
250
251 0 ▶ my $content = get($url) || "";
Condition0%0/2
&get($url) || ''
l!l
00
MC/DC0%0/1
&get($url) || ''
&get($url)
Truth table0%0/2
A
A= &get($url)
Aresult
11
00
252
253 0 return $content;
254 }
255  
256  
257 1 1;
258 __END__
↑ Summary