<commit_before><?php
/**
 * This file is part of the Tmdb PHP API created by <NAME>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package Tmdb
 * @author <NAME> <<EMAIL>>
 * @copyright (c) 2013, <NAME>
 * @version 0.0.1
 */
namespace Tmdb\Repository;

use Tmdb\Exception\RuntimeException;
use Tmdb\Factory\TvEpisodeFactory;
use Tmdb\Model\Collection\Videos;
use Tmdb\Model\Common\Video;
use Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse;
use Tmdb\Model\Tv;
use Tmdb\Model\Tv\Season;
use Tmdb\Model\Tv\Episode;

/**
 * Class TvEpisodeRepository
 * @package Tmdb\Repository
 * @see http://docs.themoviedb.apiary.io/#tvepisodes
 */
class TvEpisodeRepository extends AbstractRepository
{
    /**
     * Load a tv season with the given identifier
     *
     * If you want to optimize the result set/bandwidth you should
     * define the AppendToResponse parameter
     *
     * @param $tvShow Tv|integer
     * @param $season Season|integer
     * @param $episode Episode|integer
     * @param $parameters
     * @param $headers
     * @throws RuntimeException
     * @return null|\Tmdb\Model\AbstractModel
     */
    public function load($tvShow, $season, $episode, array $parameters = array(), array $headers = array())
    {
        if ($tvShow instanceof Tv) {
            $tvShow = $tvShow->getId();
        }

        if ($season instanceof Season) {
            $season = $season->getId();
        }

        if ($episode instanceof Tv\Episode) {
            $episode = $episode->getId();
        }

        if (null == $tvShow || null == $season || null == $episode) {
            throw new RuntimeException('Not all required parameters to load an tv episode are present.');
        }

        if (empty($parameters)) {
            $parameters = array(
                new AppendToResponse(array(
                    AppendToResponse::CREDITS,
                    AppendToResponse::EXTERNAL_IDS,
                    AppendToResponse::IMAGES,
                    AppendToResponse::CHANGES
                ))
            );
        }

        $data = $this->getApi()->getEpisode(
            $tvShow,
            $season,
            $episode,
            $this->parseQueryParameters($parameters),
            $headers
        );
var_dump($data);exit;

        return $this->getFactory()->create($data);
    }

    /**
     * Get the cast & crew information about a TV series.
     *
     * Just like the website, we pull this information from the last season of the series.
     *
     * @param $tvShow
     * @param $season
     * @param $episode
     * @param $parameters
     * @param $headers
     * @return null|\Tmdb\Model\AbstractModel
     */
    public function getCredits($tvShow, $season, $episode, array $parameters = array(), array $headers = array())
    {
        if ($tvShow instanceof Tv) {
            $tvShow = $tvShow->getId();<commit_msg>Something sneaked in that shouldent have.<commit_after><?php
/**
 * This file is part of the Tmdb PHP API created by <NAME>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package Tmdb
 * @author <NAME> <<EMAIL>>
 * @copyright (c) 2013, <NAME>
 * @version 0.0.1
 */
namespace Tmdb\Repository;

use Tmdb\Exception\RuntimeException;
use Tmdb\Factory\TvEpisodeFactory;
use Tmdb\Model\Collection\Videos;
use Tmdb\Model\Common\Video;
use Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse;
use Tmdb\Model\Tv;
use Tmdb\Model\Tv\Season;
use Tmdb\Model\Tv\Episode;

/**
 * Class TvEpisodeRepository
 * @package Tmdb\Repository
 * @see http://docs.themoviedb.apiary.io/#tvepisodes
 */
class TvEpisodeRepository extends AbstractRepository
{
    /**
     * Load a tv season with the given identifier
     *
     * If you want to optimize the result set/bandwidth you should
     * define the AppendToResponse parameter
     *
     * @param $tvShow Tv|integer
     * @param $season Season|integer
     * @param $episode Episode|integer
     * @param $parameters
     * @param $headers
     * @throws RuntimeException
     * @return null|\Tmdb\Model\AbstractModel
     */
    public function load($tvShow, $season, $episode, array $parameters = array(), array $headers = array())
    {
        if ($tvShow instanceof Tv) {
            $tvShow = $tvShow->getId();
        }

        if ($season instanceof Season) {
            $season = $season->getId();
        }

        if ($episode instanceof Tv\Episode) {
            $episode = $episode->getId();
        }

        if (null == $tvShow || null == $season || null == $episode) {
            throw new RuntimeException('Not all required parameters to load an tv episode are present.');
        }

        if (empty($parameters)) {
            $parameters = array(
                new AppendToResponse(array(
                    AppendToResponse::CREDITS,
                    AppendToResponse::EXTERNAL_IDS,
                    AppendToResponse::IMAGES,
                    AppendToResponse::CHANGES
                ))
            );
        }

        $data = $this->getApi()->getEpisode(
            $tvShow,
            $season,
            $episode,
            $this->parseQueryParameters($parameters),
            $headers
        );

        return $this->getFactory()->create($data);
    }

    /**
     * Get the cast & crew information about a TV series.
     *
     * Just like the website, we pull this information from the last season of the series.
     *
     * @param $tvShow
     * @param $season
     * @param $episode
     * @param $parameters
     * @param $headers
     * @return null|\Tmdb\Model\AbstractModel
     */
    public function getCredits($tvShow, $season, $episode, array $parameters = array(), array $headers = array())
    {
        if ($tvShow instanceof Tv) {
            $tvShow = $tvShow->getId();
{'fraction_non_alphanumeric': 0.11594202898550725, 'fraction_numerical': 0.0023592854735422987, 'mean_word_length': 2.2538377192982457, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7238712', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1706, 'n_words': 467}