ldc-cocotte/domain/Models/ValueObjects/ContactFormData.php
Jérémy Munsch d1d0585b34
fix(contact): update orderRef to use OrderReference value object
Refactor orderRef handling in contact forms to ensure proper validation and type safety.
2026-11-15 16:45:05 +01:00

34 lines
985 B
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 ?OrderReference $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');
}
}
}