diff --git a/lib/Tmdb/Model/Collection/Images.php b/lib/Tmdb/Model/Collection/Images.php index 121981cd..bafaaeea 100644 --- a/lib/Tmdb/Model/Collection/Images.php +++ b/lib/Tmdb/Model/Collection/Images.php @@ -12,8 +12,10 @@ */ namespace Tmdb\Model\Collection; +use Tmdb\Factory\ImageFactory; use Tmdb\Model\Common\Collection; +use Tmdb\Model\Filter\ImageFilter; use Tmdb\Model\Image; class Images extends Collection { @@ -63,7 +65,7 @@ public function filterPosters() { return $this->filter( function($key, $value) { - if ($value instanceof Image\PosterImage) { return true; } + if ($value instanceof ImageFilter && $value instanceof Image\PosterImage) { return true; } } ); } @@ -77,7 +79,7 @@ public function filterBackdrops() { return $this->filter( function($key, $value) { - if ($value instanceof Image\BackdropImage) { return true; } + if ($value instanceof ImageFilter && $value instanceof Image\BackdropImage) { return true; } } ); } @@ -91,7 +93,7 @@ public function filterProfile() { return $this->filter( function($key, $value) { - if ($value instanceof Image\ProfileImage) { return true; } + if ($value instanceof ImageFilter && $value instanceof Image\ProfileImage) { return true; } } ); } @@ -105,7 +107,7 @@ public function filterStills() { return $this->filter( function($key, $value) { - if ($value instanceof Image\StillImage) { return true; } + if ($value instanceof ImageFilter && $value instanceof Image\StillImage) { return true; } } ); } @@ -120,7 +122,7 @@ public function filterMaxWidth($width) { return $this->filter( function($key, $value) use ($width) { - if ($value->getWidth() <= $width && $value->getWidth() !== null) { return true; } + if ($value instanceof ImageFilter && $value->getWidth() <= $width && $value->getWidth() !== null) { return true; } } ); } @@ -135,7 +137,7 @@ public function filterMinWidth($width) { return $this->filter( function($key, $value) use ($width) { - if ($value->getWidth() >= $width && $value->getWidth() !== null) { return true; } + if ($value instanceof ImageFilter && $value->getWidth() >= $width && $value->getWidth() !== null) { return true; } } ); } @@ -150,7 +152,7 @@ public function filterMaxHeight($height) { return $this->filter( function($key, $value) use ($height) { - if ($value->getHeight() <= $height && $value->getHeight() !== null) { return true; } + if ($value instanceof ImageFilter && $value->getHeight() <= $height && $value->getHeight() !== null) { return true; } } ); } @@ -165,7 +167,7 @@ public function filterMinHeight($height) { return $this->filter( function($key, $value) use ($height) { - if ($value->getHeight() >= $height && $value->getHeight() !== null) { return true; } + if ($value instanceof ImageFilter && $value->getHeight() >= $height && $value->getHeight() !== null) { return true; } } ); } @@ -184,7 +186,7 @@ public function filterBestVotedImage() * @var $image Image */ foreach($this as $image) { - if ($image->getVoteAverage() > $voteAverage) { + if ($image instanceof ImageFilter && $image->getVoteAverage() > $voteAverage) { $voteAverage = $image->getVoteAverage(); $currentImage = $image; } diff --git a/lib/Tmdb/Model/Common/Collection.php b/lib/Tmdb/Model/Common/Collection.php index a7b0739b..54363c4b 100644 --- a/lib/Tmdb/Model/Common/Collection.php +++ b/lib/Tmdb/Model/Common/Collection.php @@ -13,6 +13,9 @@ namespace Tmdb\Model\Common; use Guzzle\Common\Collection as GuzzleCollection; +use Tmdb\Model\Filter\AdultFilter; +use Tmdb\Model\Filter\CountryFilter; +use Tmdb\Model\Filter\LanguageFilter; class Collection extends GuzzleCollection { protected $data = array(); @@ -70,7 +73,7 @@ public function filterLanguage($language = 'en') { return $this->filter( function($key, $value) use ($language) { - if ($value->getIso6391() == $language) { return true; } + if ($value instanceof LanguageFilter && $value->getIso6391() == $language) { return true; } } ); } @@ -85,7 +88,7 @@ public function filterCountry($country = 'US') { return $this->filter( function($key, $value) use ($country) { - if ($value->getIso31661() == $country) { return true; } + if ($value instanceof CountryFilter && $value->getIso31661() == $country) { return true; } } ); } @@ -100,7 +103,7 @@ public function filterAdult($adult = false) { return $this->filter( function($key, $value) use ($adult) { - if ($value->getAdult() == $adult) { return true; } + if ($value instanceof AdultFilter && $value->getAdult() == $adult) { return true; } } ); } diff --git a/lib/Tmdb/Model/Common/Country.php b/lib/Tmdb/Model/Common/Country.php index 03d6bcbe..fb20f4e6 100644 --- a/lib/Tmdb/Model/Common/Country.php +++ b/lib/Tmdb/Model/Common/Country.php @@ -12,7 +12,10 @@ */ namespace Tmdb\Model\Common; -class Country extends AbstractModel { +use Tmdb\Model\AbstractModel; +use Tmdb\Model\Filter\CountryFilter; + +class Country extends AbstractModel implements CountryFilter { private $iso31661; private $name; diff --git a/lib/Tmdb/Model/Common/SpokenLanguage.php b/lib/Tmdb/Model/Common/SpokenLanguage.php index b3d21f15..d9dfb070 100644 --- a/lib/Tmdb/Model/Common/SpokenLanguage.php +++ b/lib/Tmdb/Model/Common/SpokenLanguage.php @@ -12,7 +12,7 @@ */ namespace Tmdb\Model\Common; -class SpokenLanguage extends AbstractModel { +class SpokenLanguage extends AbstractModel implements LanguageFilter { private $iso6391; private $name; diff --git a/lib/Tmdb/Model/Common/Translation.php b/lib/Tmdb/Model/Common/Translation.php index 12d4c8b6..6b5c531f 100644 --- a/lib/Tmdb/Model/Common/Translation.php +++ b/lib/Tmdb/Model/Common/Translation.php @@ -13,8 +13,9 @@ namespace Tmdb\Model\Common; use Tmdb\Model\AbstractModel; +use Tmdb\Model\Filter\LanguageFilter; -class Translation extends AbstractModel { +class Translation extends AbstractModel implements LanguageFilter { private $iso6391; private $name; diff --git a/lib/Tmdb/Model/Filter/AdultFilter.php b/lib/Tmdb/Model/Filter/AdultFilter.php new file mode 100644 index 00000000..0ac9337c --- /dev/null +++ b/lib/Tmdb/Model/Filter/AdultFilter.php @@ -0,0 +1,17 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Filter; + +interface AdultFilter { + public function getAdult(); +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Filter/CountryFilter.php b/lib/Tmdb/Model/Filter/CountryFilter.php new file mode 100644 index 00000000..d77a259a --- /dev/null +++ b/lib/Tmdb/Model/Filter/CountryFilter.php @@ -0,0 +1,17 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Filter; + +interface CountryFilter { + public function getIso31661(); +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Filter/ImageFilter.php b/lib/Tmdb/Model/Filter/ImageFilter.php new file mode 100644 index 00000000..cae02dd1 --- /dev/null +++ b/lib/Tmdb/Model/Filter/ImageFilter.php @@ -0,0 +1,16 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Filter; + +interface ImageFilter { +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Filter/LanguageFilter.php b/lib/Tmdb/Model/Filter/LanguageFilter.php new file mode 100644 index 00000000..cc66b63c --- /dev/null +++ b/lib/Tmdb/Model/Filter/LanguageFilter.php @@ -0,0 +1,17 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Model\Filter; + +interface LanguageFilter { + public function getIso6391(); +} \ No newline at end of file diff --git a/lib/Tmdb/Model/Image.php b/lib/Tmdb/Model/Image.php index 469f2acc..b5435708 100644 --- a/lib/Tmdb/Model/Image.php +++ b/lib/Tmdb/Model/Image.php @@ -12,7 +12,10 @@ */ namespace Tmdb\Model; -class Image extends AbstractModel { +use Tmdb\Model\Filter\ImageFilter; +use Tmdb\Model\Filter\LanguageFilter; + +class Image extends AbstractModel implements ImageFilter, LanguageFilter { const FORMAT_POSTER = 'poster'; const FORMAT_BACKDROP = 'backdrop'; diff --git a/lib/Tmdb/Model/Movie/AlternativeTitle.php b/lib/Tmdb/Model/Movie/AlternativeTitle.php index b7db2e4a..6541e763 100644 --- a/lib/Tmdb/Model/Movie/AlternativeTitle.php +++ b/lib/Tmdb/Model/Movie/AlternativeTitle.php @@ -13,8 +13,9 @@ namespace Tmdb\Model\Movie; use Tmdb\Model\AbstractModel; +use Tmdb\Model\Filter\CountryFilter; -class AlternativeTitle extends AbstractModel { +class AlternativeTitle extends AbstractModel implements CountryFilter { private $iso31661; private $title; diff --git a/lib/Tmdb/Model/Movie/Release.php b/lib/Tmdb/Model/Movie/Release.php index 89856062..2e48dc48 100644 --- a/lib/Tmdb/Model/Movie/Release.php +++ b/lib/Tmdb/Model/Movie/Release.php @@ -13,8 +13,9 @@ namespace Tmdb\Model\Movie; use Tmdb\Model\AbstractModel; +use Tmdb\Model\Filter\CountryFilter; -class Release extends AbstractModel { +class Release extends AbstractModel implements CountryFilter { private $iso31661; private $certification;