diff --git a/src/Model/Promotion.php b/src/Model/Promotion.php index 852b915..f6705a0 100644 --- a/src/Model/Promotion.php +++ b/src/Model/Promotion.php @@ -61,13 +61,7 @@ public function __construct() public function __toString(): string { - $name = (string) $this->getName(); - - if ('' === $name) { - return (string) $this->getId(); - } - - return $name; + return (string) ($this->getName() ?? $this->getCode() ?? $this->getId()); } public function getMultiplier(): float @@ -75,13 +69,6 @@ public function getMultiplier(): float return 1 - $this->getDiscount(); } - public function getChannelCodes(): array - { - return $this->channels->map(static function (BaseChannelInterface $channel): string { - return (string) $channel->getCode(); - })->toArray(); - } - public function getId(): ?int { return $this->id; @@ -211,11 +198,6 @@ public function getDiscount(): float return (float) $this->discount; } - public function getDisplayableDiscount(): float - { - return $this->getDiscount() * 100; - } - public function setDiscount(float $discount): void { $this->discount = (string) $discount; diff --git a/src/Model/PromotionInterface.php b/src/Model/PromotionInterface.php index 0e138c3..fa6aa47 100644 --- a/src/Model/PromotionInterface.php +++ b/src/Model/PromotionInterface.php @@ -11,19 +11,12 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Model\TimestampableInterface; -interface PromotionInterface extends ChannelsAwareInterface, CodeAwareInterface, TimestampableInterface, ResourceInterface +interface PromotionInterface extends ChannelsAwareInterface, CodeAwareInterface, TimestampableInterface, ResourceInterface, \Stringable { public function getId(): ?int; - public function __toString(): string; - public function getMultiplier(): float; - /** - * @return string[] - */ - public function getChannelCodes(): array; - public function getName(): ?string; public function setName(?string $name): void; @@ -72,7 +65,5 @@ public function removeRule(PromotionRuleInterface $rule): void; public function getDiscount(): float; - public function getDisplayableDiscount(): float; - public function setDiscount(float $discount): void; }