Пример #1
0
 /**
  * {@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;
 }
Пример #2
0
Файл: Crew.php Проект: n10ty/api
 /**
  * Retrieve a crew member from the collection
  *
  * @param $id
  * @return Person
  */
 public function getCrewMember($id)
 {
     return parent::getPerson($id);
 }
Пример #3
0
 /**
  * @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));
 }