/**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @test
  * @covers Plum\PlumCollection\ItemConverter::convert()
  */
 public function convertConvertsArrayToItem()
 {
     $this->collection->shouldReceive('add')->once();
     $item = $this->converter->convert('foo');
     $this->assertInstanceOf('Cocur\\Collection\\Item', $item);
 }
Exemplo n.º 3
0
 /**
  * @param mixed $item
  *
  * @return Item
  */
 public function convert($item)
 {
     $item = Item::create($item);
     $this->collection->add($item);
     return $item;
 }