forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3d7331
commit cea794f
Showing
9 changed files
with
344 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?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\Factory; | ||
|
||
use Tmdb\Model\Common\GenericCollection; | ||
use Tmdb\Model\Find; | ||
|
||
class FindFactory extends AbstractFactory | ||
{ | ||
/** | ||
* @var MovieFactory | ||
*/ | ||
private $movieFactory; | ||
|
||
/** | ||
* @var PeopleFactory | ||
*/ | ||
private $peopleFactory; | ||
|
||
/** | ||
* @var TvFactory | ||
*/ | ||
private $tvFactory; | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->movieFactory = new MovieFactory(); | ||
$this->peopleFactory = new PeopleFactory(); | ||
$this->tvFactory = new TvFactory(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create(array $data = array()) | ||
{ | ||
$find = new Find(); | ||
|
||
if (array_key_exists('movie_results', $data)) { | ||
$find->setMovieResults($this->getMovieFactory()->createCollection($data['movie_results'])); | ||
} | ||
|
||
if (array_key_exists('person_results', $data)) { | ||
$find->setPersonResults($this->getPeopleFactory()->createCollection($data['person_results'])); | ||
} | ||
|
||
if (array_key_exists('tv_results', $data)) { | ||
$find->setTvResults($this->getTvFactory()->createCollection($data['tv_results'])); | ||
} | ||
|
||
return $find; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createCollection(array $data = array()) | ||
{ | ||
return array(); | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Factory\MovieFactory $movieFactory | ||
* @return $this | ||
*/ | ||
public function setMovieFactory($movieFactory) | ||
{ | ||
$this->movieFactory = $movieFactory; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Factory\MovieFactory | ||
*/ | ||
public function getMovieFactory() | ||
{ | ||
return $this->movieFactory; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Factory\PeopleFactory $peopleFactory | ||
* @return $this | ||
*/ | ||
public function setPeopleFactory($peopleFactory) | ||
{ | ||
$this->peopleFactory = $peopleFactory; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Factory\PeopleFactory | ||
*/ | ||
public function getPeopleFactory() | ||
{ | ||
return $this->peopleFactory; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Factory\TvFactory $tvFactory | ||
* @return $this | ||
*/ | ||
public function setTvFactory($tvFactory) | ||
{ | ||
$this->tvFactory = $tvFactory; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Factory\TvFactory | ||
*/ | ||
public function getTvFactory() | ||
{ | ||
return $this->tvFactory; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?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; | ||
|
||
use Tmdb\Model\Collection\People; | ||
use Tmdb\Model\Common\GenericCollection; | ||
|
||
class Find extends AbstractModel { | ||
|
||
/** | ||
* @var GenericCollection | ||
*/ | ||
private $movieResults; | ||
|
||
/** | ||
* @var People | ||
*/ | ||
private $personResults; | ||
|
||
/** | ||
* @var GenericCollection | ||
*/ | ||
private $tvResults; | ||
|
||
/** | ||
* @param \Tmdb\Model\Common\GenericCollection $movieResults | ||
* @return $this | ||
*/ | ||
public function setMovieResults($movieResults) | ||
{ | ||
$this->movieResults = $movieResults; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Model\Common\GenericCollection | ||
*/ | ||
public function getMovieResults() | ||
{ | ||
return $this->movieResults; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Model\Collection\People $personResults | ||
* @return $this | ||
*/ | ||
public function setPersonResults($personResults) | ||
{ | ||
$this->personResults = $personResults; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Model\Collection\People | ||
*/ | ||
public function getPersonResults() | ||
{ | ||
return $this->personResults; | ||
} | ||
|
||
/** | ||
* @param \Tmdb\Model\Common\GenericCollection $tvResults | ||
* @return $this | ||
*/ | ||
public function setTvResults($tvResults) | ||
{ | ||
$this->tvResults = $tvResults; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return \Tmdb\Model\Common\GenericCollection | ||
*/ | ||
public function getTvResults() | ||
{ | ||
return $this->tvResults; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?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\Tests\Factory; | ||
|
||
use Tmdb\Model\Find; | ||
|
||
class FindFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldConstructFind() | ||
{ | ||
$factory = $this->getFactory(); | ||
|
||
/** | ||
* @var Find $find | ||
*/ | ||
$find = $factory->create(array( | ||
'movie_results' => array(array('id' => 1)), | ||
'person_results' => array(array('id' => 1)), | ||
'tv_results' => array(array('id' => 1)), | ||
)); | ||
|
||
$this->assertInstanceOf('Tmdb\Model\Find', $find); | ||
|
||
foreach($find->getMovieResults() as $movie) { | ||
$this->assertInstanceOf('Tmdb\Model\Movie', $movie); | ||
} | ||
|
||
foreach($find->getPersonResults() as $person) { | ||
$this->assertInstanceOf('Tmdb\Model\Person', $person); | ||
} | ||
|
||
foreach($find->getTvResults() as $tv) { | ||
$this->assertInstanceOf('Tmdb\Model\Tv', $tv); | ||
} | ||
} | ||
|
||
protected function getFactoryClass() | ||
{ | ||
return 'Tmdb\Factory\FindFactory'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.