Skip to content

Commit

Permalink
Merge pull request #59 from vfalies/feature/TVShowCredit
Browse files Browse the repository at this point in the history
Feature/tvShowCredit
  • Loading branch information
vfalies authored Aug 20, 2021
2 parents 5854948 + 356646b commit 856ecb4
Show file tree
Hide file tree
Showing 15 changed files with 493 additions and 43 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.12] - 2021-08-20

### Updated
- Remove PHPUnit result cache file during tests
### Added

- Add getCast() / getCrew() methods to TVShow / TVSeason / TVEpisode object

## [1.11] - 2021-04-29
### Updated
- Compatibility code & tests from PHP 7.1 to PHP 8.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: clean coverage

test:
vendor/bin/phpunit
vendor/bin/phpunit --do-not-cache-result

coverage:
vendor/bin/phpunit --coverage-html=logs/build/coverage
Expand Down
9 changes: 2 additions & 7 deletions src/VfacTmdb/Interfaces/Results/CastResultsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/


Expand All @@ -18,7 +18,7 @@
* Interface for Cast results type object
* @package Tmdb
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/
interface CastResultsInterface
{
Expand All @@ -41,11 +41,6 @@ public function getCharacter() : string;
*/
public function getGender() : int;

/**
* Cast Id
* @return int
*/
public function getCastId() : int;

/**
* Name
Expand Down
23 changes: 21 additions & 2 deletions src/VfacTmdb/Items/TVEpisode.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/


Expand All @@ -24,7 +24,7 @@
* TVEpisode class
* @package Tmdb
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/
class TVEpisode extends TVItem implements TVEpisodeInterface
{
Expand Down Expand Up @@ -207,4 +207,23 @@ public function getChanges(array $options = array()) : \Generator
$changes = $this->getItemChanges($options);
return $changes->getChanges();
}
/**
* Get TVShow episode crew
* @return \Generator|Results\Crew
*/
public function getCrew() : \Generator
{
$credit = new TVEpisodeCredit($this->tmdb, $this->tv_id, $this->season_number, $this->episode_number);
return $credit->getCrew();
}

/**
* Get TVShow episode cast
* @return \Generator|Results\Cast
*/
public function getCast() : \Generator
{
$cast = new TVEpisodeCredit($this->tmdb, $this->tv_id, $this->season_number, $this->episode_number);
return $cast->getCast();
}
}
100 changes: 100 additions & 0 deletions src/VfacTmdb/Items/TVEpisodeCredit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php declare(strict_types=1);
/**
* This file is part of the Tmdb package.
*
* (c) Vincent Faliès <vincent@vfac.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017-2021
*/


namespace VfacTmdb\Items;

use VfacTmdb\Results;
use VfacTmdb\Interfaces\TmdbInterface;

/**
* TVSeason Credit class
* @package Tmdb
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017-2021
*/
class TVEpisodeCredit
{
/**
* Tmdb object
* @var TmdbInterface
*/
private $tmdb = null;
/**
* Logger object
* @var \Psr\Log\LoggerInterface
*/
protected $logger = null;
/**
* Params
* @var array
*/
protected $params = null;
/**
* Data
* @var \stdClass
*/
protected $data = null;
/**
* Crew
* @var \stdClass
*/
protected $crew;
/**
* Options array
* @var array
*/
protected $options;

/**
* Constructor
* @param TmdbInterface $tmdb
* @param int $tvshow_id
* @param array $options
*/
public function __construct(TmdbInterface $tmdb, int $tv_id, int $season_number, int $episode_number, array $options = array())
{
$this->tmdb = $tmdb;
$this->logger = $tmdb->getLogger();
$this->data = $this->tmdb->getRequest('tv/' . $tv_id . '/season/'.$season_number.'/episode/'.$episode_number.'/credits');
$this->options = $options;
}

/**
* Crew
* @return \Generator|Results\Crew
*/
public function getCrew() : \Generator
{
if (!empty($this->data->crew)) {
foreach ($this->data->crew as $c) {
$crew = new Results\Crew($this->tmdb, $c);
yield $crew;
}
}
}

/**
* Cast
* @return \Generator|Results\Cast
*/
public function getCast() : \Generator
{
if (!empty($this->data->cast)) {
foreach ($this->data->cast as $c) {
$cast = new Results\Cast($this->tmdb, $c);
yield $cast;
}
}
}
}
25 changes: 23 additions & 2 deletions src/VfacTmdb/Items/TVSeason.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/


Expand All @@ -24,7 +24,7 @@
* TVSeason class
* @package Tmdb
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/
class TVSeason extends TVItem implements TVSeasonInterface
{
Expand Down Expand Up @@ -153,4 +153,25 @@ public function getChanges(array $options = array()) : \Generator
$changes = $this->getItemChanges($options);
return $changes->getChanges();
}


/**
* Get TVShow Season crew
* @return \Generator|Results\Crew
*/
public function getCrew() : \Generator
{
$credit = new TVSeasonCredit($this->tmdb, $this->tv_id, $this->season_number);
return $credit->getCrew();
}

/**
* Get TVShow Season cast
* @return \Generator|Results\Cast
*/
public function getCast() : \Generator
{
$cast = new TVSeasonCredit($this->tmdb, $this->tv_id, $this->season_number);
return $cast->getCast();
}
}
100 changes: 100 additions & 0 deletions src/VfacTmdb/Items/TVSeasonCredit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php declare(strict_types=1);
/**
* This file is part of the Tmdb package.
*
* (c) Vincent Faliès <vincent@vfac.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017-2021
*/


namespace VfacTmdb\Items;

use VfacTmdb\Results;
use VfacTmdb\Interfaces\TmdbInterface;

/**
* TVSeason Credit class
* @package Tmdb
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017-2021
*/
class TVSeasonCredit
{
/**
* Tmdb object
* @var TmdbInterface
*/
private $tmdb = null;
/**
* Logger object
* @var \Psr\Log\LoggerInterface
*/
protected $logger = null;
/**
* Params
* @var array
*/
protected $params = null;
/**
* Data
* @var \stdClass
*/
protected $data = null;
/**
* Crew
* @var \stdClass
*/
protected $crew;
/**
* Options array
* @var array
*/
protected $options;

/**
* Constructor
* @param TmdbInterface $tmdb
* @param int $tvshow_id
* @param array $options
*/
public function __construct(TmdbInterface $tmdb, int $tv_id, int $season_number, array $options = array())
{
$this->tmdb = $tmdb;
$this->logger = $tmdb->getLogger();
$this->data = $this->tmdb->getRequest('tv/' . $tv_id . '/season/'.$season_number.'/credits');
$this->options = $options;
}

/**
* Crew
* @return \Generator|Results\Crew
*/
public function getCrew() : \Generator
{
if (!empty($this->data->crew)) {
foreach ($this->data->crew as $c) {
$crew = new Results\Crew($this->tmdb, $c);
yield $crew;
}
}
}

/**
* Cast
* @return \Generator|Results\Cast
*/
public function getCast() : \Generator
{
if (!empty($this->data->cast)) {
foreach ($this->data->cast as $c) {
$cast = new Results\Cast($this->tmdb, $c);
yield $cast;
}
}
}
}
25 changes: 23 additions & 2 deletions src/VfacTmdb/Items/TVShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* file that was distributed with this source code.
*
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/


Expand All @@ -24,7 +24,7 @@
* TVShow class
* @package Tmdb
* @author Vincent Faliès <vincent@vfac.fr>
* @copyright Copyright (c) 2017
* @copyright Copyright (c) 2017-2021
*/
class TVShow extends Item implements TVShowInterface
{
Expand Down Expand Up @@ -240,6 +240,27 @@ public function getSimilar() : \Generator
}
}


/**
* Get TVShow crew
* @return \Generator|Results\Crew
*/
public function getCrew() : \Generator
{
$credit = new TVShowCredit($this->tmdb, $this->id);
return $credit->getCrew();
}

/**
* Get TVShow cast
* @return \Generator|Results\Cast
*/
public function getCast() : \Generator
{
$cast = new TVShowCredit($this->tmdb, $this->id);
return $cast->getCast();
}

/**
* Get the underlying ItemChanges object for this Item
* @param array $options Array of options for the request
Expand Down
Loading

0 comments on commit 856ecb4

Please sign in to comment.