public function __toString() { $items = $this->items->getArrayCopy(); $itemStrings = array_map(function (Item $item) { return $item->__toString() . "\n"; }, $items); return implode($itemStrings); }
/** * @return Collection|Item[] */ public function getItems() { return $this->items->sortBy(function (Item $item) { return $item->getWeight(); }); }
/** * Remove item * * @param Item $item Item * * @return $this */ public function removeItem(Item $item) { $this->items->removeElement($item); return $this; }
/** * @return Item[] */ public function getItems() { return $this->items->toArray(); }
public function testNearestUseBy() { $oneMinLater = strtotime('+1 minute'); $this->items['bread']->setUseBy($oneMinLater); $this->assertEquals($oneMinLater, $this->items->getNearestUseBy()); }
/** * 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); }