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

34 lines
983 B
PHP

<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
use Carbon\CarbonImmutable;
final readonly class EmployeeImport
{
public function __construct(
public Matricule $matricule,
public string $nom,
public string $prenom,
public string $etablissement,
public string $service,
public string $site,
public CarbonImmutable $startDate,
public ?CarbonImmutable $endDate,
) {
$this->assertNotEmpty($nom, 'Name is required');
$this->assertNotEmpty($prenom, 'First name is required');
$this->assertNotEmpty($etablissement, 'The establishment is required');
$this->assertNotEmpty($service, 'The service is required');
$this->assertNotEmpty($site, 'The site is required');
}
private function assertNotEmpty(string $value, string $message): void
{
if (trim($value) === '') {
throw new \DomainException($message);
}
}
}