34 lines
863 B
PHP
34 lines
863 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects\Coupon;
|
|
|
|
use Domain\Enums\Country;
|
|
use Shared\DDD\Models\Equatable;
|
|
|
|
final readonly class CouponProductInfo implements Equatable
|
|
{
|
|
public function __construct(
|
|
public string $name,
|
|
public string $range,
|
|
public string $validityText,
|
|
public Country $forLocale
|
|
) {
|
|
$trimmed = trim($this->name);
|
|
|
|
if ($trimmed === '') {
|
|
throw new \DomainException('Product Info name cannot be empty.');
|
|
}
|
|
}
|
|
|
|
#[\Override]
|
|
public function equals(mixed $other): bool
|
|
{
|
|
return $other instanceof self
|
|
&& $this->name === $other->name
|
|
&& $this->range === $other->range
|
|
&& $this->validityText === $other->validityText
|
|
&& $this->forLocale->equals($other->forLocale);
|
|
}
|
|
}
|