ldc-boutique-cnc-sable/domain/Models/ValueObjects/ContactFormData.php
2026-10-27 09:58:12 +01:00

37 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
final readonly class ContactFormData
{
public function __construct(
public string $lastName,
public string $firstName,
public string $email,
public string $subject,
public string $message,
public ?string $orderRef = null,
public ?AttachedFile $file = null,
) {
if (trim($lastName) === '') {
throw new \DomainException('lastName cannot be empty');
}
if (trim($firstName) === '') {
throw new \DomainException('firstName cannot be empty');
}
if (trim($email) === '') {
throw new \DomainException('email cannot be empty');
}
if (trim($subject) === '') {
throw new \DomainException('subject cannot be empty');
}
if (trim($message) === '') {
throw new \DomainException('message cannot be empty');
}
if ($orderRef !== null && trim($orderRef) === '') {
throw new \DomainException('orderRef cannot be empty if provided');
}
}
}