ldc-boutique-cnc-sable/domain/Events/Dto/OrderPlacedShop.php
Jérémy Munsch c8f895c759
refactor: simplify use statements and type hints
- Removed fully qualified names for better readability.
- Streamlined code by using direct class references.
2026-10-29 20:35:35 +01:00

40 lines
1 KiB
PHP

<?php
declare(strict_types=1);
namespace Domain\Events\Dto;
use Domain\Models\ValueObjects\DeliveryAddress;
final readonly class OrderPlacedShop
{
public function __construct(
public string $name,
public string $address,
public string $postcode,
public string $city,
) {
if (empty(trim($name))) {
throw new \DomainException('Shop name is required');
}
if (empty(trim($address))) {
throw new \DomainException('Shop address is required');
}
if (empty(trim($postcode))) {
throw new \DomainException('Shop postcode is required');
}
if (empty(trim($city))) {
throw new \DomainException('Shop city is required');
}
}
public static function fromDeliveryAddress(DeliveryAddress $address): self
{
return new self(
name: $address->name,
address: $address->address,
postcode: $address->postcode,
city: $address->city,
);
}
}