Exemplo n.º 1
0
 public function __toString()
 {
     $items = $this->items->getArrayCopy();
     $itemStrings = array_map(function (Item $item) {
         return $item->__toString() . "\n";
     }, $items);
     return implode($itemStrings);
 }
Exemplo n.º 2
0
 /**
  * @return Collection|Item[]
  */
 public function getItems()
 {
     return $this->items->sortBy(function (Item $item) {
         return $item->getWeight();
     });
 }
Exemplo n.º 3
0
 /**
  * Remove item
  *
  * @param Item $item Item
  *
  * @return $this
  */
 public function removeItem(Item $item)
 {
     $this->items->removeElement($item);
     return $this;
 }
Exemplo n.º 4
0
 /**
  * @return Item[]
  */
 public function getItems()
 {
     return $this->items->toArray();
 }
Exemplo n.º 5
0
 public function testNearestUseBy()
 {
     $oneMinLater = strtotime('+1 minute');
     $this->items['bread']->setUseBy($oneMinLater);
     $this->assertEquals($oneMinLater, $this->items->getNearestUseBy());
 }
Exemplo n.º 6
0
 /**
  * Offset to unset
  * @link  http://php.net/manual/en/arrayaccess.offsetunset.php
  *
  * @param mixed $offset <p>
  *                      The offset to unset.
  *                      </p>
  *
  * @return void
  * @since 5.0.0
  */
 public function offsetUnset($offset)
 {
     $this->items->forget($offset);
 }