Skip to content

Commit

Permalink
Fixing some issues indicated by Scrutinizer
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Jan 26, 2014
1 parent 59a0591 commit 608bd93
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/Tmdb/Api/Genres.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Genres
*/
public function getGenre($id, array $options = array(), array $headers = array())
{
$response = $this->getGenres();
$response = $this->getGenres($options, $headers);

if (array_key_exists('genres', $response)) {
foreach($response['genres'] as $genre) {
Expand Down
5 changes: 3 additions & 2 deletions lib/Tmdb/Factory/AbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@
namespace Tmdb\Factory;

use Tmdb\Common\ObjectHydrator;
use Tmdb\Factory\Common\GenericCollectionFactory;
use Tmdb\Model\AbstractModel;

abstract class AbstractFactory {
/**
* Convert an array to an hydrated object
*
* @param array $data
* @return $this
* @return AbstractModel
*/
abstract public static function create(array $data = array());

/**
* Convert an array with an collection of items to an hydrated object collection
*
* @param array $data
* @return $this
* @return GenericCollectionFactory
*/
abstract public static function createCollection(array $data = array());

Expand Down
47 changes: 38 additions & 9 deletions lib/Tmdb/Factory/ImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
class ImageFactory extends AbstractFactory
{
/**
* {@inheritdoc}
* Convert an array to an hydrated object
*
* @param array $data
* @param string $key
* @return Image
*/
public static function create(array $data = array(), $key = null)
{
Expand All @@ -40,7 +44,7 @@ public static function create(array $data = array(), $key = null)
*
* @param $path
* @param string $key
* @return \Tmdb\Model\Image
* @return Image
*/
public static function createFromPath($path, $key)
{
Expand Down Expand Up @@ -73,6 +77,10 @@ public static function getPossibleKeys()
);
}

/**
* @param null $key
* @return Image|Image\BackdropImage|Image\LogoImage|Image\PosterImage|Image\ProfileImage|Image\StillImage
*/
private function resolveImageType($key = null)
{
switch($key) {
Expand Down Expand Up @@ -116,7 +124,10 @@ private function resolveImageType($key = null)
}

/**
* {@inheritdoc}
* Create generic collection
*
* @param array $data
* @return Images
*/
public static function createCollection(array $data = array())
{
Expand All @@ -130,7 +141,10 @@ public static function createCollection(array $data = array())
}

/**
* {@inheritdoc}
* Create full collection
*
* @param array $data
* @return Images
*/
public static function createImageCollection(array $data = array())
{
Expand All @@ -150,39 +164,54 @@ public static function createImageCollection(array $data = array())
}

/**
* {@inheritdoc}
* Create full movie collection
*
* @param array $data
* @return Images
*/
public static function createCollectionFromMovie(array $data = array())
{
return self::createImageCollection($data);
}

/**
* {@inheritdoc}
* Create full tv show collection
*
* @param array $data
* @return Images
*/
public static function createCollectionFromTv(array $data = array())
{
return self::createImageCollection($data);
}

/**
* {@inheritdoc}
* Create full tv season collection
*
* @param array $data
* @return Images
*/
public static function createCollectionFromTvSeason(array $data = array())
{
return self::createImageCollection($data);
}

/**
* {@inheritdoc}
* Create full tv episode collection
*
* @param array $data
* @return Images
*/
public static function createCollectionFromTvEpisode(array $data = array())
{
return self::createImageCollection($data);
}

/**
* {@inheritdoc}
* Create full people collection
*
* @param array $data
* @return Images
*/
public static function createCollectionFromPeople(array $data = array())
{
Expand Down
3 changes: 0 additions & 3 deletions lib/Tmdb/Model/Tv.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
use Tmdb\Model\Collection\Images;
use Tmdb\Model\Collection\People;

use Tmdb\Model\Common\Translation;
use Tmdb\Model\Tv\CastMember;
use Tmdb\Model\Tv\CrewMember;
use Tmdb\Model\Tv\ExternalIds;
use Tmdb\Model\Tv\Network;

Expand Down
10 changes: 7 additions & 3 deletions lib/Tmdb/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ public function getClient()
protected function parseQueryParameters(array $parameters = array())
{
foreach($parameters as $key => $candidate) {
if ($candidate instanceof QueryParameterInterface) {
unset($parameters[$key]);
if (is_object($candidate)) {
$interfaces = class_implements($candidate);

$parameters[$candidate->getKey()] = $candidate->getValue();
if (array_key_exists('Tmdb\Model\Common\QueryParameter\QueryParameterInterface', $interfaces)) {
unset($parameters[$key]);

$parameters[$candidate->getKey()] = $candidate->getValue();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Repository/TvEpisodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Tmdb\Factory\TvEpisodeFactory;
use Tmdb\Model\Common\GenericCollection;

use \Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse;
use Tmdb\Model\Tv\Episode\QueryParameter\AppendToResponse;

use Tmdb\Model\Tv;
use Tmdb\Model\Tv\Season;
Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Repository/TvRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Tv;

use \Tmdb\Model\Tv\QueryParameter\AppendToResponse;
use Tmdb\Model\Tv\QueryParameter\AppendToResponse;

class TvRepository extends AbstractRepository {

Expand Down

0 comments on commit 608bd93

Please sign in to comment.