-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from php-tmdb/TvEpisodeGroups
Tv episode groups
- Loading branch information
Showing
19 changed files
with
1,162 additions
and
9 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
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,46 @@ | ||
<?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 sheriffmarley | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 4.0.0 | ||
*/ | ||
|
||
namespace Tmdb\Api; | ||
|
||
/** | ||
* Class TvEpisode | ||
* @package Tmdb\Api | ||
* @see http://docs.themoviedb.apiary.io/#tvepisodes | ||
*/ | ||
class TvEpisodeGroup extends AbstractApi | ||
{ | ||
/** | ||
* Get the primary information about a TV episode group by it's id. | ||
* | ||
* @param $episode_group | ||
* @param array $parameters | ||
* @param array $headers | ||
* @return mixed | ||
*/ | ||
public function getEpisodeGroup( | ||
$episode_group, | ||
array $parameters = [], | ||
array $headers = [] | ||
) { | ||
return $this->get( | ||
sprintf( | ||
'tv/episode_group/%s', | ||
$episode_group | ||
), | ||
$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
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,84 @@ | ||
<?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 sheriffmarley | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 4.0.0 | ||
*/ | ||
|
||
namespace Tmdb\Factory; | ||
|
||
use Tmdb\Model\Network; | ||
use Tmdb\Model\AbstractModel; | ||
use Tmdb\Model\Tv\EpisodeGroup; | ||
use Tmdb\HttpClient\HttpClient; | ||
use Tmdb\Model\Common\GenericCollection; | ||
|
||
/** | ||
* Class TvEpisodeGroupFactory | ||
* @package Tmdb\Factory | ||
*/ | ||
class TvEpisodeGroupFactory extends AbstractFactory | ||
{ | ||
|
||
/** | ||
* @var TvEpisodeGroupsFactory | ||
*/ | ||
private $tvEpisodeGroupsFactory; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param HttpClient $httpClient | ||
*/ | ||
public function __construct(HttpClient $httpClient) | ||
{ | ||
$this->tvEpisodeGroupsFactory = new TvEpisodeGroupsFactory($httpClient); | ||
|
||
parent::__construct($httpClient); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createCollection(array $data = []) | ||
{ | ||
$collection = new GenericCollection(); | ||
|
||
foreach ($data as $item) { | ||
$collection->add(null, $this->create($item)); | ||
} | ||
|
||
return $collection; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return AbstractModel|null | ||
*/ | ||
public function create(array $data = []): ?AbstractModel | ||
{ | ||
if (!$data) { | ||
return null; | ||
} | ||
|
||
$episodeGroup = new EpisodeGroup(); | ||
|
||
if (array_key_exists('network', $data) && !is_null($data['network'])) { | ||
$episodeGroup->setNetwork($this->hydrate(new Network(), $data['network'])); | ||
} | ||
|
||
if (array_key_exists('groups', $data) && $data['groups'] !== null) { | ||
$episodeGroup->setGroups($this->tvEpisodeGroupsFactory->createCollection($data['groups'])); | ||
} | ||
|
||
return $this->hydrate($episodeGroup, $data); | ||
} | ||
} |
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,99 @@ | ||
<?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 sheriffmarley | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 4.0.0 | ||
*/ | ||
|
||
namespace Tmdb\Factory; | ||
|
||
use Tmdb\Model\AbstractModel; | ||
use Tmdb\HttpClient\HttpClient; | ||
use Tmdb\Model\Tv\TvEpisodeGroup; | ||
use Tmdb\Model\Common\GenericCollection; | ||
|
||
/** | ||
* Class TvEpisodeGroupsFactory | ||
* @package Tmdb\Factory | ||
*/ | ||
class TvEpisodeGroupsFactory extends AbstractFactory | ||
{ | ||
|
||
/** | ||
* @var TvEpisodeFactory | ||
*/ | ||
private $tvEpisodeFactory; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param HttpClient $httpClient | ||
*/ | ||
public function __construct(HttpClient $httpClient) | ||
{ | ||
$this->tvEpisodeFactory = new TvEpisodeFactory($httpClient); | ||
|
||
parent::__construct($httpClient); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createCollection(array $data = []) | ||
{ | ||
$collection = new GenericCollection(); | ||
|
||
foreach ($data as $item) { | ||
$collection->add(null, $this->create($item)); | ||
} | ||
|
||
return $collection; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return AbstractModel|null | ||
*/ | ||
public function create(array $data = []): ?AbstractModel | ||
{ | ||
if (!$data) { | ||
return null; | ||
} | ||
|
||
$tvEpisodeGroup = new TvEpisodeGroup(); | ||
|
||
/** Episodes */ | ||
if (array_key_exists('episodes', $data) && $data['episodes'] !== null) { | ||
$tvEpisodeGroup->setEpisodes($this->getTvEpisodeFactory()->createCollection($data['episodes'])); | ||
} | ||
|
||
return $this->hydrate($tvEpisodeGroup, $data); | ||
} | ||
|
||
/** | ||
* @return TvEpisodeFactory | ||
*/ | ||
public function getTvEpisodeFactory() | ||
{ | ||
return $this->tvEpisodeFactory; | ||
} | ||
|
||
/** | ||
* @param TvEpisodeFactory $tvEpisodeFactory | ||
* @return $this | ||
*/ | ||
public function setTvEpisodeFactory($tvEpisodeFactory) | ||
{ | ||
$this->tvEpisodeFactory = $tvEpisodeFactory; | ||
|
||
return $this; | ||
} | ||
} |
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
Oops, something went wrong.