public function asEntityCollection(array $data, $entityClass)
 {
     $collection = new EntityCollection();
     foreach ($data as $record) {
         $collection->addItem(new $entityClass($record));
     }
     return $collection;
 }
 public function testShowAddAnItem()
 {
     $item = new Organization(['id' => 1, 'name' => 'Foo bar']);
     $collection = new EntityCollection();
     $collection->addItem($item);
     $this->assertCount(1, $collection);
     $this->assertEquals($item, $collection[0]);
 }
Example #3
0
 /**
  * Retrieve all organizations
  *
  * @return EntityCollection
  */
 public function all()
 {
     $search_items = $this->request->get('/organizations');
     $collection = new EntityCollection();
     foreach ($search_items as $item) {
         $collection->addItem(new OrganizationEntity($item));
     }
     return $collection;
 }