From 89db493a34fae78f94e98c8478ad2ba7ebc923ac Mon Sep 17 00:00:00 2001 From: Adriel Kloppenburg Date: Tue, 8 Nov 2016 17:01:27 +1300 Subject: [PATCH 1/3] Missing equals + error checking added The = was missing from the getAllShowsByPage function uri, as well as some error checking if the user is trying to get a page that has no content. --- TVMaze/TVMazeClient.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/TVMaze/TVMazeClient.php b/TVMaze/TVMazeClient.php index 7917983..a98e022 100644 --- a/TVMaze/TVMazeClient.php +++ b/TVMaze/TVMazeClient.php @@ -347,18 +347,21 @@ public function getAllShowsByPage($page = null) if ($page == null) { $url = self::API_URL . '/shows'; } else { - $url = self::API_URL . '/shows?page' . $page; + $url = self::API_URL . '/shows?page=' . $page; } $shows = $this->getFile($url); $relevant_shows = []; - foreach ($shows as $series) { - $TVShow = new TVShow($series); - $relevant_shows[] = $TVShow; + if ($shows) { + foreach ($shows as $series) { + $TVShow = new TVShow($series); + $relevant_shows[] = $TVShow; + } + return $relevant_shows; + }else { + return false; } - - return $relevant_shows; } /** From e9ec5eaf17588396ad5d3a8b57b98082eb37eb99 Mon Sep 17 00:00:00 2001 From: Octav Date: Thu, 10 Nov 2016 11:44:43 +0200 Subject: [PATCH 2/3] Update TVMazeClient.php --- TVMaze/TVMazeClient.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/TVMaze/TVMazeClient.php b/TVMaze/TVMazeClient.php index a98e022..eba5805 100644 --- a/TVMaze/TVMazeClient.php +++ b/TVMaze/TVMazeClient.php @@ -351,17 +351,17 @@ public function getAllShowsByPage($page = null) } $shows = $this->getFile($url); - + if (false === $shows) { + return false; + } + $relevant_shows = []; - if ($shows) { - foreach ($shows as $series) { - $TVShow = new TVShow($series); - $relevant_shows[] = $TVShow; - } - return $relevant_shows; - }else { - return false; + foreach ($shows as $series) { + $TVShow = new TVShow($series); + $relevant_shows[] = $TVShow; } + + return $relevant_shows; } /** From b4fcac23c35f4d55795aa44394f63af391eab2bc Mon Sep 17 00:00:00 2001 From: Octav Date: Thu, 10 Nov 2016 11:45:15 +0200 Subject: [PATCH 3/3] Update TVMazeClient.php --- TVMaze/TVMazeClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TVMaze/TVMazeClient.php b/TVMaze/TVMazeClient.php index eba5805..c4b306e 100644 --- a/TVMaze/TVMazeClient.php +++ b/TVMaze/TVMazeClient.php @@ -354,13 +354,13 @@ public function getAllShowsByPage($page = null) if (false === $shows) { return false; } - + $relevant_shows = []; foreach ($shows as $series) { $TVShow = new TVShow($series); $relevant_shows[] = $TVShow; } - + return $relevant_shows; }