/**
  * The discount amount as a negative price.
  *
  * @throws \InvalidArgumentException
  *
  * @return Money
  */
 public function linePrice() : Money
 {
     if (!$this->requirementsAreMet()) {
         return Money::fromInt(0);
     }
     if ($this->offer->isAbsolute()) {
         return $this->priceFromAbsolute();
     }
     return $this->priceFromRelative();
 }
Beispiel #2
0
 /**
  * @return string
  */
 private function byPercentage() : string
 {
     $saving = $this->offer->percentage;
     if ($this->offer->isAbsolute()) {
         $saving = 100 - $this->offer->percentage;
     }
     if ($this->offer->quantity > 1) {
         return "{$saving}% off when you buy {$this->offer->quantity}";
     }
     return "{$saving}% off";
 }