25 lines
611 B
PHP
25 lines
611 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects\Coupon;
|
|
|
|
use Domain\Models\ValueObjects\Period;
|
|
|
|
final readonly class CouponDiffusion
|
|
{
|
|
public function __construct(
|
|
/** @var Period[] */
|
|
public array $periods,
|
|
) {
|
|
if ($this->periods === []) {
|
|
throw new \DomainException('Diffusion requires at least one period.');
|
|
}
|
|
|
|
foreach ($this->periods as $period) {
|
|
if (!$period instanceof Period) {
|
|
throw new \DomainException('CouponDiffusion periods must be Period instances.');
|
|
}
|
|
}
|
|
}
|
|
}
|