30 lines
878 B
PHP
30 lines
878 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects;
|
|
|
|
final readonly class OrderEmployee
|
|
{
|
|
public function __construct(
|
|
public readonly Matricule $matricule,
|
|
public readonly string $firstname,
|
|
public readonly string $lastname,
|
|
public readonly string $facility,
|
|
public readonly string $site,
|
|
public readonly string $service,
|
|
) {
|
|
$this->assertNotEmpty('firstname', $firstname);
|
|
$this->assertNotEmpty('lastname', $lastname);
|
|
$this->assertNotEmpty('facility', $facility);
|
|
$this->assertNotEmpty('site', $site);
|
|
$this->assertNotEmpty('service', $service);
|
|
}
|
|
|
|
private function assertNotEmpty(string $attribute, string $value): void
|
|
{
|
|
if (empty(trim($value))) {
|
|
throw new \DomainException("{$attribute} cannot be empty");
|
|
}
|
|
}
|
|
}
|