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