Skip to content

Commit f5a7852

Browse files
committed
Merge pull request #74 from wtfzdotnet/scrutinizer-issues
Scrutinizer issues
2 parents 6f1f0b7 + 1bb2c93 commit f5a7852

25 files changed

+104
-132
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"require": {
1616
"php": ">=5.4.0",
1717
"ext-curl": "*",
18-
"symfony/event-dispatcher": "~2.1",
18+
"symfony/event-dispatcher": "~2.4",
1919
"symfony/options-resolver": "~2.1",
2020
"guzzlehttp/guzzle": "~5.0",
2121
"guzzlehttp/cache-subscriber": "~0.1@dev",

examples/find/api/get.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$token = new \Tmdb\ApiToken(TMDB_API_KEY);
1717
$client = new \Tmdb\Client($token);
1818

19-
$find = $client->getFindApi()->find('tt0120737', [
19+
$find = $client->getFindApi()->findBy('tt0120737', [
2020
'external_source' => 'imdb_id'
2121
]);
2222

examples/find/model/get.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
$client = new \Tmdb\Client($token);
1818

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

2222
var_dump($find);

lib/Tmdb/Api/Find.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Find extends AbstractApi
3737
* @param array $headers
3838
* @return mixed
3939
*/
40-
public function find($id, array $parameters = [], array $headers = [])
40+
public function findBy($id, array $parameters = [], array $headers = [])
4141
{
4242
return $this->get(
4343
sprintf('find/%s', $id),

lib/Tmdb/ConfigurationInterface.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* For the full copyright and license information, please view the LICENSE
66
* file that was distributed with this source code.
7-
*
7+
*
88
* @package Shop2Market
99
* @author Michael Roterman <[email protected]>
1010
* @copyright (c) 2014, B-Found Internet Marketing & Services
@@ -13,6 +13,7 @@
1313

1414
namespace Tmdb;
1515

16-
interface ConfigurationInterface {
17-
function all();
18-
}
16+
interface ConfigurationInterface
17+
{
18+
public function all();
19+
}

lib/Tmdb/Event/HydrationSubscriber.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
namespace Tmdb\Event;
1414

15+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1516
use Tmdb\Common\ObjectHydrator;
1617
use Tmdb\HttpClient\HttpClientEventSubscriber;
1718

@@ -36,13 +37,16 @@ public static function getSubscribedEvents()
3637
/**
3738
* Hydrate the subject with data
3839
*
39-
* @param HydrationEvent $event
40+
* @param HydrationEvent $event
41+
* @param string $eventName
42+
* @param EventDispatcherInterface $eventDispatcher
43+
*
4044
* @return \Tmdb\Model\AbstractModel
4145
*/
42-
public function hydrate(HydrationEvent $event)
46+
public function hydrate(HydrationEvent $event, $eventName, $eventDispatcher)
4347
{
4448
// Possibility to load serialized cache
45-
$event->getDispatcher()->dispatch(TmdbEvents::BEFORE_HYDRATION, $event);
49+
$eventDispatcher->dispatch(TmdbEvents::BEFORE_HYDRATION, $event);
4650

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

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

5761
return $event->getSubject();
5862
}

lib/Tmdb/Event/RequestSubscriber.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
namespace Tmdb\Event;
1414

15+
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1516
use Tmdb\Exception\RuntimeException;
1617
use Tmdb\HttpClient\HttpClientEventSubscriber;
1718
use Tmdb\HttpClient\Response;
@@ -29,10 +30,17 @@ public static function getSubscribedEvents()
2930
];
3031
}
3132

32-
public function send(RequestEvent $event)
33+
/**
34+
* @param RequestEvent $event
35+
* @param string $eventName
36+
* @param EventDispatcherInterface $eventDispatcher
37+
*
38+
* @return string|Response
39+
*/
40+
public function send(RequestEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
3341
{
3442
// Preparation of request parameters / Possibility to use for logging and caching etc.
35-
$event->getDispatcher()->dispatch(TmdbEvents::BEFORE_REQUEST, $event);
43+
$eventDispatcher->dispatch(TmdbEvents::BEFORE_REQUEST, $event);
3644

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

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

4755
return $response;
4856
}
@@ -56,8 +64,6 @@ public function send(RequestEvent $event)
5664
*/
5765
public function sendRequest(RequestEvent $event)
5866
{
59-
$response = null;
60-
6167
switch ($event->getMethod()) {
6268
case 'GET':
6369
$response = $this->getHttpClient()->getAdapter()->get($event->getRequest());

lib/Tmdb/Exception/TmdbApiException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class TmdbApiException extends \Exception
4343
/**
4444
* Create the exception
4545
*
46-
* @param string $message
47-
* @param int $code
48-
* @param null $request
49-
* @param null $response
46+
* @param string $message
47+
* @param int $code
48+
* @param Request|null $request
49+
* @param Response|null $response
5050
*/
5151
public function __construct($code, $message, $request = null, $response = null)
5252
{

lib/Tmdb/Factory/Common/VideoFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ private function resolveVideoType($data)
6262
switch ($site) {
6363
case 'youtube':
6464
return new Video\Youtube();
65-
break;
6665
default:
6766
return new Video();
68-
break;
6967
}
7068
}
7169
}

lib/Tmdb/Factory/FindFactory.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ class FindFactory extends AbstractFactory
3636
*/
3737
private $tvFactory;
3838

39+
/**
40+
* @var TvSeasonFactory
41+
*/
42+
private $tvSeasonFactory;
43+
44+
/**
45+
* @var TvEpisodeFactory
46+
*/
47+
private $tvEpisodeFactory;
48+
3949
/**
4050
* Constructor
4151
*
@@ -46,7 +56,7 @@ public function __construct(HttpClient $httpClient)
4656
$this->movieFactory = new MovieFactory($httpClient);
4757
$this->peopleFactory = new PeopleFactory($httpClient);
4858
$this->tvFactory = new TvFactory($httpClient);
49-
$this->tvSeasonFactory = new TvFactory($httpClient);
59+
$this->tvSeasonFactory = new TvSeasonFactory($httpClient);
5060
$this->tvEpisodeFactory = new TvEpisodeFactory($httpClient);
5161

5262
parent::__construct($httpClient);
@@ -171,15 +181,15 @@ public function setTvEpisodeFactory($tvEpisodeFactory)
171181
}
172182

173183
/**
174-
* @return TvFactory
184+
* @return TvSeasonFactory
175185
*/
176186
public function getTvSeasonFactory()
177187
{
178188
return $this->tvSeasonFactory;
179189
}
180190

181191
/**
182-
* @param TvFactory $tvSeasonFactory
192+
* @param TvSeasonFactory $tvSeasonFactory
183193
* @return $this
184194
*/
185195
public function setTvSeasonFactory($tvSeasonFactory)

0 commit comments

Comments
 (0)