ldc-cocotte/domain/Models/ValueObjects/ShopPickupOverride.php

24 lines
677 B
PHP
Raw Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
use Carbon\CarbonInterface;
use Domain\Models\Entities\PickupExceptionOnDate;
final readonly class ShopPickupOverride
{
public function __construct(
public PickupExceptionOnDate $exception,
public ?CarbonInterface $replacementDate = null,
public ?CarbonInterface $orderDeadlineAt = null
) {
if ($orderDeadlineAt !== null && $replacementDate !== null && $orderDeadlineAt->greaterThanOrEqualTo($replacementDate)) {
throw new \DomainException(
'Order deadline must be strictly before the replacement date'
);
}
}
}