Beispiel #1
0
 public function removeProduct(UuidIdentity $id)
 {
     $element = $this->lineItems->filter(function (LineItem $lineItem) use($id) {
         return $lineItem->getProduct()->getId()->getValue() === $id->getValue();
     })->first();
     if ($element) {
         $this->lineItems->removeElement($element);
     }
     return $this;
 }
Beispiel #2
0
 /**
  * @return Money
  */
 public function getTotal() : Money
 {
     $total = new Money(0);
     $this->lineItems->map(function (LineItem $lineItem) use(&$total) {
         $total = $total->add($lineItem->getPrice());
     });
     return $total;
 }
 /**
  * @param LineItem $item
  *
  * @return $this
  */
 public function removeLineItem(LineItem $item)
 {
     if ($this->lineItems->contains($item)) {
         $this->lineItems->removeElement($item);
     }
     return $this;
 }