Skip to content

Commit

Permalink
Reviewing Models
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Jan 29, 2014
1 parent ad9408b commit 43253b4
Show file tree
Hide file tree
Showing 31 changed files with 284 additions and 166 deletions.
4 changes: 4 additions & 0 deletions lib/Tmdb/Factory/TvEpisodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public function create(array $data = array())
$tvEpisode->setImages($this->getImageFactory()->createCollectionFromTvEpisode($data['images']));
}

if (array_key_exists('still_path', $data)) {
$tvEpisode->setStill($this->getImageFactory()->createFromPath($data['still_path'], 'still_path'));
}

return $this->hydrate($tvEpisode, $data);
}

Expand Down
8 changes: 8 additions & 0 deletions lib/Tmdb/Factory/TvFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public function create(array $data = array())
$tvShow->setImages($this->getImageFactory()->createCollectionFromTv($data['images']));
}

if (array_key_exists('backdrop_path', $data)) {
$tvShow->setBackdrop($this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'));
}

if (array_key_exists('poster_path', $data)) {
$tvShow->setPoster($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
}

/** Translations */
if (array_key_exists('translations', $data)) {
$tvShow->setTranslations($this->createGenericCollection($data['translations']['translations'], new Translation()));
Expand Down
4 changes: 4 additions & 0 deletions lib/Tmdb/Factory/TvSeasonFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public function create(array $data = array())
$tvSeason->setImages($this->getImageFactory()->createCollectionFromTvSeason($data['images']));
}

if (array_key_exists('poster_path', $data)) {
$tvSeason->setPoster($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
}

/** Episodes */
if (array_key_exists('episodes', $data)) {
$tvSeason->setEpisodes($this->getTvEpisodeFactory()->createCollection($data['episodes']));
Expand Down
4 changes: 2 additions & 2 deletions lib/Tmdb/Model/Change.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Change extends AbstractModel {
*/
public function setAdult($adult)
{
$this->adult = $adult;
$this->adult = (bool) $adult;
return $this;
}

Expand All @@ -55,7 +55,7 @@ public function getAdult()
*/
public function setId($id)
{
$this->id = $id;
$this->id = (int) $id;
return $this;
}

Expand Down
78 changes: 0 additions & 78 deletions lib/Tmdb/Model/Changes/Change.php

This file was deleted.

10 changes: 5 additions & 5 deletions lib/Tmdb/Model/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __construct()
* @param \Tmdb\Model\Image\BackdropImage $backdrop
* @return $this
*/
public function setBackdrop($backdrop)
public function setBackdrop(BackdropImage $backdrop)
{
$this->backdrop = $backdrop;
return $this;
Expand Down Expand Up @@ -114,7 +114,7 @@ public function getBackdropPath()
*/
public function setId($id)
{
$this->id = $id;
$this->id = (int) $id;
return $this;
}

Expand All @@ -130,7 +130,7 @@ public function getId()
* @param \Tmdb\Model\Collection\Images $images
* @return $this
*/
public function setImages($images)
public function setImages(Images $images)
{
$this->images = $images;
return $this;
Expand Down Expand Up @@ -173,7 +173,7 @@ public function setParts($parts)
}

/**
* @return \Tmdb\Model\Common\Collection
* @return GenericCollection
*/
public function getParts()
{
Expand All @@ -184,7 +184,7 @@ public function getParts()
* @param \Tmdb\Model\Image\PosterImage $poster
* @return $this
*/
public function setPoster($poster)
public function setPoster(PosterImage $poster)
{
$this->poster = $poster;
return $this;
Expand Down
8 changes: 4 additions & 4 deletions lib/Tmdb/Model/Common/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Country extends AbstractModel implements CountryFilter {
);

/**
* @param mixed $iso31661
* @param string $iso31661
* @return $this
*/
public function setIso31661($iso31661)
Expand All @@ -36,15 +36,15 @@ public function setIso31661($iso31661)
}

/**
* @return mixed
* @return string
*/
public function getIso31661()
{
return $this->iso31661;
}

/**
* @param mixed $name
* @param string $name
* @return $this
*/
public function setName($name)
Expand All @@ -54,7 +54,7 @@ public function setName($name)
}

/**
* @return mixed
* @return string
*/
public function getName()
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Common/GenericCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ public function add($key, $value)
/**
* Remove a specific key value pair
*
* @param string $key A key to remove
* @param string $key A key to remove or an object in the same state
*
* @return GenericCollection
*/
public function remove($key)
{
if ($key === null && is_object($value)) {
$key = spl_object_hash($value);
if (is_object($key)) {
$key = spl_object_hash($key);
}

unset($this->data[$key]);
Expand Down
39 changes: 39 additions & 0 deletions lib/Tmdb/Model/Common/QueryParameter/Adult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
namespace Tmdb\Model\Common\QueryParameter;

class Adult implements QueryParameterInterface {

private $adult;

public function __construct($adult)
{
$this->adult = $adult;
}

/**
* @return string
*/
public function getKey()
{
return 'adult';
}

/**
* @return string
*/
public function getValue()
{
return $this->adult;
}
}
8 changes: 4 additions & 4 deletions lib/Tmdb/Model/Common/SpokenLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SpokenLanguage extends AbstractModel implements LanguageFilter {
);

/**
* @param mixed $iso6391
* @param string $iso6391
* @return $this
*/
public function setIso6391($iso6391)
Expand All @@ -36,15 +36,15 @@ public function setIso6391($iso6391)
}

/**
* @return mixed
* @return string
*/
public function getIso6391()
{
return $this->iso6391;
}

/**
* @param mixed $name
* @param string $name
* @return $this
*/
public function setName($name)
Expand All @@ -54,7 +54,7 @@ public function setName($name)
}

/**
* @return mixed
* @return string
*/
public function getName()
{
Expand Down
16 changes: 8 additions & 8 deletions lib/Tmdb/Model/Common/Trailer/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getUrl()
}

/**
* @param mixed $name
* @param string $name
* @return $this
*/
public function setName($name)
Expand All @@ -53,15 +53,15 @@ public function setName($name)
}

/**
* @return mixed
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @param mixed $size
* @param string $size
* @return $this
*/
public function setSize($size)
Expand All @@ -71,15 +71,15 @@ public function setSize($size)
}

/**
* @return mixed
* @return string
*/
public function getSize()
{
return $this->size;
}

/**
* @param mixed $source
* @param string $source
* @return $this
*/
public function setSource($source)
Expand All @@ -89,15 +89,15 @@ public function setSource($source)
}

/**
* @return mixed
* @return string
*/
public function getSource()
{
return $this->source;
}

/**
* @param mixed $type
* @param string $type
* @return $this
*/
public function setType($type)
Expand All @@ -107,7 +107,7 @@ public function setType($type)
}

/**
* @return mixed
* @return string
*/
public function getType()
{
Expand Down
Loading

0 comments on commit 43253b4

Please sign in to comment.