コード例 #1
0
 /**
  * @param mixed $item
  *
  * @return ArrayItem
  *
  * @throws RuntimeException if the given item is not an array
  */
 public function convert($item)
 {
     if (!is_array($item)) {
         throw new RuntimeException('The given item must be an array.');
     }
     $item = ArrayItem::createFromArray($item);
     $this->collection->add($item);
     return $item;
 }
コード例 #2
0
ファイル: ArrayItemTest.php プロジェクト: cocur/collection
 /**
  * @test
  * @covers Cocur\Collection\ArrayItem::createFromArray()
  */
 public function createFromArrayReturnsNewInstance()
 {
     $item = ArrayItem::createFromArray(['foo' => 'bar']);
     $this->assertSame('bar', $item['foo']);
 }