26 lines
597 B
PHP
26 lines
597 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects\Coupon;
|
|
|
|
use Shared\DDD\Models\Equatable;
|
|
use DateTime;
|
|
|
|
final readonly class CouponValidity implements Equatable
|
|
{
|
|
public function __construct(
|
|
public int $days,
|
|
public DateTime $until
|
|
) {
|
|
if ($this->days <= 0) {
|
|
throw new \DomainException('Coupon Validity days must be positive.');
|
|
}
|
|
}
|
|
|
|
#[\Override]
|
|
public function equals(mixed $other): bool
|
|
{
|
|
return $other instanceof self && $this->days === $other->days && $this->until == $other->until;
|
|
}
|
|
}
|