forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
ec08a4c
commit e104cf7
Showing
6 changed files
with
226 additions
and
0 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,23 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
require_once('../../../vendor/autoload.php'); | ||
require_once('../../../apikey.php'); | ||
|
||
$token = new \Tmdb\ApiToken(TMDB_API_KEY); | ||
$client = new \Tmdb\Client($token); | ||
|
||
|
||
$repository = new \Tmdb\Repository\NetworkRepository($client); | ||
$network = $repository->load(49); | ||
|
||
var_dump($network); |
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,33 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Api; | ||
|
||
class Networks | ||
extends AbstractApi | ||
{ | ||
/** | ||
* This method is used to retrieve the basic information about a TV network. | ||
* | ||
* You can use this ID to search for TV shows with the discover. | ||
* At this time we don't have much but this will be fleshed out over time. | ||
* | ||
* @param int $network_id | ||
* @param array $parameters | ||
* @param array $headers | ||
* @return mixed | ||
*/ | ||
public function getNetwork($network_id, array $parameters = array(), array $headers = array()) | ||
{ | ||
return $this->get('network/' . $network_id, $parameters, $headers); | ||
} | ||
} |
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
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,49 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Factory; | ||
|
||
use Tmdb\Model\Collection\Networks; | ||
use Tmdb\Model\Common\GenericCollection; | ||
use Tmdb\Model\Network; | ||
use Tmdb\Model\Movie; | ||
|
||
class NetworkFactory extends AbstractFactory | ||
{ | ||
/** | ||
* @param array $data | ||
* | ||
* @return Network | ||
*/ | ||
public function create(array $data = array()) | ||
{ | ||
return $this->hydrate(new Network(), $data); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createCollection(array $data = array()) | ||
{ | ||
$collection = new GenericCollection(); | ||
|
||
if (array_key_exists('networks', $data)) { | ||
$data = $data['networks']; | ||
} | ||
|
||
foreach($data as $item) { | ||
$collection->add(null, $this->create($item)); | ||
} | ||
|
||
return $collection; | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Model; | ||
|
||
class Network extends AbstractModel { | ||
|
||
private $id; | ||
private $name; | ||
|
||
public static $_properties = array( | ||
'id', | ||
'name', | ||
); | ||
|
||
/** | ||
* @param mixed $id | ||
* @return $this | ||
*/ | ||
public function setId($id) | ||
{ | ||
$this->id = (int) $id; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return integer | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param mixed $name | ||
* @return $this | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Repository; | ||
|
||
use Tmdb\Factory\NetworkFactory; | ||
use Tmdb\Model\Network; | ||
|
||
class NetworkRepository extends AbstractRepository { | ||
/** | ||
* This method is used to retrieve the basic information about a TV network. | ||
* | ||
* You can use this ID to search for TV shows with the discover. | ||
* At this time we don't have much but this will be fleshed out over time. | ||
* | ||
* @param $id | ||
* @param array $parameters | ||
* @param array $headers | ||
* @return Network | ||
*/ | ||
public function load($id, array $parameters = array(), array $headers = array()) { | ||
return $this->getFactory()->create( | ||
$this->getApi()->getNetwork($id, $parameters, $headers) | ||
); | ||
} | ||
|
||
/** | ||
* Return the related API class | ||
* | ||
* @return \Tmdb\Api\Networks | ||
*/ | ||
public function getApi() | ||
{ | ||
return $this->getClient()->getNetworksApi(); | ||
} | ||
|
||
/** | ||
* @return NetworkFactory | ||
*/ | ||
public function getFactory() | ||
{ | ||
return new NetworkFactory(); | ||
} | ||
} |