Example #1
0
 /**
  * @test
  */
 public function shouldCreateCollection()
 {
     $this->assertEquals(true, !empty($this->changes));
     $this->assertEquals(1, $this->changes->getPage());
     $this->assertEquals(12, $this->changes->getTotalPages());
     $this->assertEquals(1151, $this->changes->getTotalResults());
     $this->assertEquals(100, count($this->changes));
 }
 /**
  * {@inheritdoc}
  */
 public function createCollection(array $data = [])
 {
     $collection = new Changes();
     if (array_key_exists('page', $data)) {
         $collection->setPage($data['page']);
     }
     if (array_key_exists('total_pages', $data)) {
         $collection->setTotalPages($data['total_pages']);
     }
     if (array_key_exists('total_results', $data)) {
         $collection->setTotalResults($data['total_results']);
     }
     if (array_key_exists('results', $data)) {
         $data = $data['results'];
     }
     foreach ($data as $item) {
         $collection->add(null, $this->create($item));
     }
     return $collection;
 }