コード例 #1
0
ファイル: CollectionAbstract.php プロジェクト: gpupo/common
 public function toArray()
 {
     $list = parent::toArray();
     foreach ($list as $key => $value) {
         if ($value instanceof self) {
             $list[$key] = $value->toArray();
         }
     }
     return $list;
 }
コード例 #2
0
ファイル: ArrayCollectionTest.php プロジェクト: gpupo/common
 public function testGet()
 {
     $elements = [1, 'A' => 'a', 2, 'null' => null, 3, 'A2' => 'a', 'zero' => 0];
     $collection = new ArrayCollection($elements);
     $this->assertSame(2, $collection->get(1), 'Get element by index');
     $this->assertSame('a', $collection->get('A'), 'Get element by name');
     $this->assertSame(null, $collection->get('non-existent'), 'Get non existent element');
 }