コード例 #1
0
 public function asEntityCollection(array $data, $entityClass)
 {
     $collection = new EntityCollection();
     foreach ($data as $record) {
         $collection->addItem(new $entityClass($record));
     }
     return $collection;
 }
コード例 #2
0
ファイル: Organization.php プロジェクト: vsmoraes/daredesync
 /**
  * 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;
 }
コード例 #3
0
 public function testShowAddMultipleItems()
 {
     $items = [new Organization(['id' => 1, 'name' => 'Foo bar']), new Organization(['id' => 2, 'name' => 'Bar baz']), new Organization(['id' => 3, 'name' => 'Baz foo'])];
     $collection = new EntityCollection();
     $collection->addItems($items);
     $this->assertCount(3, $collection);
     $this->assertEquals($items[0], $collection[0]);
     $this->assertEquals($items[1], $collection[1]);
     $this->assertEquals($items[2], $collection[2]);
 }