public function __construct(PromotionType $type) { parent::__construct($type); $this->entityDTO->isFixed = $this->entity->isFixed(); $this->entityDTO->isPercent = $this->entity->isPercent(); $this->entityDTO->isExact = $this->entity->isExact(); }
/** * @param int $unitPrice * @return int */ public function getUnitPrice($unitPrice) { $returnValue = 0; if ($this->type->isFixed()) { $returnValue = $unitPrice - $this->value; } elseif ($this->type->isPercent()) { $returnValue = $unitPrice - $unitPrice * ($this->value / 100); } elseif ($this->type->isExact()) { $returnValue = $this->value; } return (int) $returnValue; }