Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"symfony/event-dispatcher": "~2.1",
"symfony/event-dispatcher": "~2.4",
"symfony/options-resolver": "~2.1",
"guzzlehttp/guzzle": "~5.0",
"guzzlehttp/cache-subscriber": "~0.1@dev",
Expand Down
2 changes: 1 addition & 1 deletion examples/find/api/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$find = $client->getFindApi()->find('tt0120737', [
$find = $client->getFindApi()->findBy('tt0120737', [
'external_source' => 'imdb_id'
]);

Expand Down
2 changes: 1 addition & 1 deletion examples/find/model/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\FindRepository($client);
$find = $repository->find('tt0120737', ['external_source' => 'imdb_id']);
$find = $repository->findBy('tt0120737', ['external_source' => 'imdb_id']);

var_dump($find);
2 changes: 1 addition & 1 deletion lib/Tmdb/Api/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Find extends AbstractApi
* @param array $headers
* @return mixed
*/
public function find($id, array $parameters = [], array $headers = [])
public function findBy($id, array $parameters = [], array $headers = [])
{
return $this->get(
sprintf('find/%s', $id),
Expand Down
9 changes: 5 additions & 4 deletions lib/Tmdb/ConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*
* @package Shop2Market
* @author Michael Roterman <michael@b-found.nl>
* @copyright (c) 2014, B-Found Internet Marketing & Services
Expand All @@ -13,6 +13,7 @@

namespace Tmdb;

interface ConfigurationInterface {
function all();
}
interface ConfigurationInterface
{
public function all();
}
12 changes: 8 additions & 4 deletions lib/Tmdb/Event/HydrationSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
namespace Tmdb\Event;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Tmdb\Common\ObjectHydrator;
use Tmdb\HttpClient\HttpClientEventSubscriber;

Expand All @@ -36,13 +37,16 @@ public static function getSubscribedEvents()
/**
* Hydrate the subject with data
*
* @param HydrationEvent $event
* @param HydrationEvent $event
* @param string $eventName
* @param EventDispatcherInterface $eventDispatcher
*
* @return \Tmdb\Model\AbstractModel
*/
public function hydrate(HydrationEvent $event)
public function hydrate(HydrationEvent $event, $eventName, $eventDispatcher)
{
// Possibility to load serialized cache
$event->getDispatcher()->dispatch(TmdbEvents::BEFORE_HYDRATION, $event);
$eventDispatcher->dispatch(TmdbEvents::BEFORE_HYDRATION, $event);

if ($event->isPropagationStopped()) {
return $event->getSubject();
Expand All @@ -52,7 +56,7 @@ public function hydrate(HydrationEvent $event)
$event->setSubject($subject);

// Possibility to cache the data
$event->getDispatcher()->dispatch(TmdbEvents::AFTER_HYDRATION, $event);
$eventDispatcher->dispatch(TmdbEvents::AFTER_HYDRATION, $event);

return $event->getSubject();
}
Expand Down
16 changes: 11 additions & 5 deletions lib/Tmdb/Event/RequestSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
namespace Tmdb\Event;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Tmdb\Exception\RuntimeException;
use Tmdb\HttpClient\HttpClientEventSubscriber;
use Tmdb\HttpClient\Response;
Expand All @@ -29,10 +30,17 @@ public static function getSubscribedEvents()
];
}

public function send(RequestEvent $event)
/**
* @param RequestEvent $event
* @param string $eventName
* @param EventDispatcherInterface $eventDispatcher
*
* @return string|Response
*/
public function send(RequestEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
// Preparation of request parameters / Possibility to use for logging and caching etc.
$event->getDispatcher()->dispatch(TmdbEvents::BEFORE_REQUEST, $event);
$eventDispatcher->dispatch(TmdbEvents::BEFORE_REQUEST, $event);

if ($event->isPropagationStopped() && $event->hasResponse()) {
return $event->getResponse();
Expand All @@ -42,7 +50,7 @@ public function send(RequestEvent $event)
$event->setResponse($response);

// Possibility to cache the request
$event->getDispatcher()->dispatch(TmdbEvents::AFTER_REQUEST, $event);
$eventDispatcher->dispatch(TmdbEvents::AFTER_REQUEST, $event);

return $response;
}
Expand All @@ -56,8 +64,6 @@ public function send(RequestEvent $event)
*/
public function sendRequest(RequestEvent $event)
{
$response = null;

switch ($event->getMethod()) {
case 'GET':
$response = $this->getHttpClient()->getAdapter()->get($event->getRequest());
Expand Down
8 changes: 4 additions & 4 deletions lib/Tmdb/Exception/TmdbApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class TmdbApiException extends \Exception
/**
* Create the exception
*
* @param string $message
* @param int $code
* @param null $request
* @param null $response
* @param string $message
* @param int $code
* @param Request|null $request
* @param Response|null $response
*/
public function __construct($code, $message, $request = null, $response = null)
{
Expand Down
2 changes: 0 additions & 2 deletions lib/Tmdb/Factory/Common/VideoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ private function resolveVideoType($data)
switch ($site) {
case 'youtube':
return new Video\Youtube();
break;
default:
return new Video();
break;
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions lib/Tmdb/Factory/FindFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ class FindFactory extends AbstractFactory
*/
private $tvFactory;

/**
* @var TvSeasonFactory
*/
private $tvSeasonFactory;

/**
* @var TvEpisodeFactory
*/
private $tvEpisodeFactory;

/**
* Constructor
*
Expand All @@ -46,7 +56,7 @@ public function __construct(HttpClient $httpClient)
$this->movieFactory = new MovieFactory($httpClient);
$this->peopleFactory = new PeopleFactory($httpClient);
$this->tvFactory = new TvFactory($httpClient);
$this->tvSeasonFactory = new TvFactory($httpClient);
$this->tvSeasonFactory = new TvSeasonFactory($httpClient);
$this->tvEpisodeFactory = new TvEpisodeFactory($httpClient);

parent::__construct($httpClient);
Expand Down Expand Up @@ -171,15 +181,15 @@ public function setTvEpisodeFactory($tvEpisodeFactory)
}

/**
* @return TvFactory
* @return TvSeasonFactory
*/
public function getTvSeasonFactory()
{
return $this->tvSeasonFactory;
}

/**
* @param TvFactory $tvSeasonFactory
* @param TvSeasonFactory $tvSeasonFactory
* @return $this
*/
public function setTvSeasonFactory($tvSeasonFactory)
Expand Down
19 changes: 0 additions & 19 deletions lib/Tmdb/Factory/People/CastFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Tmdb\Factory\People;

use Tmdb\Factory\PeopleFactory;
use Tmdb\HttpClient\HttpClient;
use Tmdb\Model\Collection\People\Cast;

/**
Expand All @@ -22,24 +21,6 @@
*/
class CastFactory extends PeopleFactory
{
/**
* Constructor
*
* @param HttpClient $httpClient
*/
public function __construct(HttpClient $httpClient)
{
parent::__construct($httpClient);
}

/**
* {@inheritdoc}
*/
public function create(array $data = [], $person = null)
{
return parent::create($data, $person);
}

/**
* {@inheritdoc}
* @param \Tmdb\Model\Person\CastMember $person
Expand Down
19 changes: 0 additions & 19 deletions lib/Tmdb/Factory/People/CrewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Tmdb\Factory\People;

use Tmdb\Factory\PeopleFactory;
use Tmdb\HttpClient\HttpClient;
use Tmdb\Model\Collection\People\Crew;

/**
Expand All @@ -22,24 +21,6 @@
*/
class CrewFactory extends PeopleFactory
{
/**
* Constructor
*
* @param HttpClient $httpClient
*/
public function __construct(HttpClient $httpClient)
{
parent::__construct($httpClient);
}

/**
* {@inheritdoc}
*/
public function create(array $data = [], $person = null)
{
return parent::create($data, $person);
}

/**
* {@inheritdoc}
* @param \Tmdb\Model\Person\CrewMember $person
Expand Down
14 changes: 8 additions & 6 deletions lib/Tmdb/HttpClient/Adapter/GuzzleAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class GuzzleAdapter extends AbstractAdapter
{
/**
* @var Client
* @var ClientInterface
*/
private $client;

Expand Down Expand Up @@ -88,9 +88,11 @@ private function createResponse(ResponseInterface $adapterResponse = null)
{
$response = new Response();

$response->setCode($adapterResponse->getStatusCode());
$response->setHeaders(new ParameterBag($adapterResponse->getHeaders()));
$response->setBody((string) $adapterResponse->getBody());
if ($adapterResponse !== null) {
$response->setCode($adapterResponse->getStatusCode());
$response->setHeaders(new ParameterBag($adapterResponse->getHeaders()));
$response->setBody((string) $adapterResponse->getBody());
}

return $response;
}
Expand All @@ -102,9 +104,9 @@ private function createResponse(ResponseInterface $adapterResponse = null)
* @param RequestException|null $previousException
* @throws \Tmdb\Exception\TmdbApiException
*/
protected function handleRequestException(Request $request, RequestException $previousException = null)
protected function handleRequestException(Request $request, RequestException $previousException)
{
if (null !== $previousException && null == $response = $previousException->getResponse()) {
if (null !== $previousException && null == $previousException->getResponse()) {
throw new NullResponseException($this->request, $previousException);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/HttpClient/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HttpClient
private $eventDispatcher;

/**
* @var ParameterBag
* @var array
*/
protected $options;

Expand Down Expand Up @@ -148,15 +148,15 @@ public function delete($path, $body = null, array $parameters = [], array $heade
}

/**
* @return ParameterBag
* @return array
*/
public function getOptions()
{
return $this->options;
}

/**
* @param ParameterBag $options
* @param array $options
* @return $this
*/
public function setOptions($options)
Expand Down
5 changes: 3 additions & 2 deletions lib/Tmdb/Model/Account/ListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Tmdb\Model\Account;

use Tmdb\Model\AbstractModel;
use Tmdb\Model\Image;
use Tmdb\Model\Image\PosterImage;

/**
Expand Down Expand Up @@ -214,7 +215,7 @@ public function getName()
}

/**
* @param \Tmdb\Model\Image\PosterImage $posterImage
* @param PosterImage|Image $posterImage
* @return $this
*/
public function setPosterImage($posterImage)
Expand All @@ -225,7 +226,7 @@ public function setPosterImage($posterImage)
}

/**
* @return \Tmdb\Model\Image\PosterImage
* @return PosterImage|Image
*/
public function getPosterImage()
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct()
}

/**
* @param \Tmdb\Model\Image\BackdropImage $backdrop
* @param BackdropImage $backdrop
* @return $this
*/
public function setBackdropImage(BackdropImage $backdrop)
Expand All @@ -94,7 +94,7 @@ public function setBackdropImage(BackdropImage $backdrop)
}

/**
* @return \Tmdb\Model\Image\BackdropImage
* @return BackdropImage
*/
public function getBackdropImage()
{
Expand Down Expand Up @@ -216,7 +216,7 @@ public function getParts()
}

/**
* @param \Tmdb\Model\Image\PosterImage $poster
* @param PosterImage $poster
* @return $this
*/
public function setPosterImage(PosterImage $poster)
Expand Down
Loading