- Add methods to convert OrderLine and DeliveryAddress to DTOs. - Introduce toPlacedEvent method in Order to generate domain event. - Enhance OrderUnit with Regate code mapping. - Implement tests for new functionality and ensure correctness.
36 lines
909 B
PHP
36 lines
909 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\Entities;
|
|
|
|
use Carbon\CarbonInterface;
|
|
use Carbon\WeekDay;
|
|
use Domain\Enums\RepeatFrequency;
|
|
use Domain\Models\ValueObjects\Entities\PickupExceptionId;
|
|
use Shared\DDD\Entity;
|
|
|
|
/** @implements \Shared\DDD\Entity<\Domain\Models\ValueObjects\Entities\PickupExceptionId> */
|
|
final readonly class PickupExceptionOnDate implements Entity
|
|
{
|
|
public function __construct(
|
|
public PickupExceptionId $id,
|
|
public CarbonInterface $date,
|
|
public string $label,
|
|
public bool $repeatable,
|
|
public RepeatFrequency $repeatFrequency,
|
|
public bool $autoUpdated
|
|
) {
|
|
}
|
|
|
|
#[\Override]
|
|
public function id(): PickupExceptionId
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function isPickupDay(WeekDay $pickupDay = WeekDay::Friday): bool
|
|
{
|
|
return $this->date->isDayOfWeek($pickupDay->value);
|
|
}
|
|
}
|