36 lines
973 B
PHP
36 lines
973 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects\CampaignRequest;
|
|
|
|
use Shared\ValueObjects\Email;
|
|
|
|
final readonly class Applicant
|
|
{
|
|
public function __construct(
|
|
public string $firstname,
|
|
public string $lastname,
|
|
public Email $email,
|
|
) {
|
|
$trimmedFirstname = mb_trim($firstname);
|
|
|
|
if ($trimmedFirstname === '') {
|
|
throw new \DomainException('Applicant firstname cannot be empty.');
|
|
}
|
|
|
|
if (mb_strlen($trimmedFirstname) > 200) {
|
|
throw new \DomainException('Applicant firstname exceeds the maximum allowed length.');
|
|
}
|
|
|
|
$trimmedLastname = mb_trim($lastname);
|
|
|
|
if ($trimmedLastname === '') {
|
|
throw new \DomainException('Applicant lastname cannot be empty.');
|
|
}
|
|
|
|
if (mb_strlen($trimmedLastname) > 200) {
|
|
throw new \DomainException('Applicant lastname exceeds the maximum allowed length.');
|
|
}
|
|
}
|
|
}
|