-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Dawson\TVDB; | ||
|
||
trait Helpers | ||
{ | ||
/** | ||
* Client | ||
* | ||
* @return TVDBClient | ||
*/ | ||
function client() | ||
{ | ||
return new TVDBClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Dawson\TVDB\Resources; | ||
|
||
use Dawson\TVDB\TVDB; | ||
|
||
class Series extends TVDB | ||
{ | ||
/** | ||
* Series ID | ||
* | ||
* @var integer | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct(int $id) | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
/** | ||
* Get the Series | ||
* | ||
* @return json | ||
*/ | ||
public function get() | ||
{ | ||
try { | ||
return json_decode($this->client()->login()->client->get('series/' . $this->id)->getBody()); | ||
} catch(ClientException $e) { | ||
throw new TVDBException($e); | ||
} | ||
} | ||
|
||
/** | ||
* Series Actors | ||
* | ||
* @return json | ||
*/ | ||
public function actors() | ||
{ | ||
try { | ||
return json_decode($this->client()->login()->client->get('series/' . $this->id . '/actors')->getBody()); | ||
} catch(ClientException $e) { | ||
throw new TVDBException($e); | ||
} | ||
} | ||
|
||
/** | ||
* Series Episodes | ||
* | ||
* @return json | ||
*/ | ||
public function episodes() | ||
{ | ||
try { | ||
return json_decode($this->client()->login()->client->get('series/' . $this->id . '/episodes')->getBody()); | ||
} catch(ClientException $e) { | ||
throw new TVDBException($e); | ||
} | ||
} | ||
|
||
/** | ||
* Series Images | ||
* | ||
* @return json | ||
*/ | ||
public function images() | ||
{ | ||
try { | ||
return json_decode($this->client()->login()->client->get('series/' . $this->id . '/images')->getBody()); | ||
} catch(ClientException $e) { | ||
throw new TVDBException($e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Dawson\TVDB; | ||
|
||
use Dawson\TVDB\Resources; | ||
|
||
class TVDB | ||
{ | ||
use Helpers; | ||
|
||
/** | ||
* Series Resource | ||
* | ||
* @param integer $id | ||
* @return \Dawson\TVDB\Resoures\Series | ||
*/ | ||
public function series($id) | ||
{ | ||
return new Resources\Series($id); | ||
} | ||
|
||
/** | ||
* Search TBDB for Series | ||
* | ||
* @param string $name | ||
* @return json | ||
*/ | ||
public function search($name) | ||
{ | ||
try { | ||
return json_decode($this->client()->login()->client->get('search/series?name=' . $name)->getBody()); | ||
} catch(ClientException $e) { | ||
throw new TVDBException($e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.