/** * {@inheritdoc} */ public function createCollection(array $data = [], $person = null, $collection = null) { if (!$collection) { $collection = new People(); } if (array_key_exists('results', $data)) { $data = $data['results']; } if (is_object($person)) { $class = get_class($person); } else { $class = '\\Tmdb\\Model\\Person'; } foreach ($data as $item) { $collection->add(null, $this->create($item, new $class())); } return $collection; }
/** * Retrieve a crew member from the collection * * @param $id * @return Person */ public function getCrewMember($id) { return parent::getPerson($id); }
/** * @test */ public function shouldGetAndSet() { $this->assertEquals(count($this->people), count($this->collection->getPeople())); $this->assertEquals('james blunt', $this->collection->getPerson(1)->getName()); $this->assertEquals(null, $this->collection->getPerson(3)); }