46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\DTOs\Import;
|
|
|
|
readonly class VacationRowDto
|
|
{
|
|
public function __construct(
|
|
public string $employeeNumber,
|
|
public ?string $type,
|
|
public ?string $startDate,
|
|
public ?string $endDate,
|
|
public ?string $returnDate,
|
|
public ?int $days,
|
|
public ?string $status,
|
|
public ?string $reason,
|
|
) {}
|
|
|
|
/**
|
|
* @param array<string, mixed> $row
|
|
*/
|
|
public static function fromMappedRow(array $row): self
|
|
{
|
|
return new self(
|
|
employeeNumber: (string) ($row['employee_number'] ?? ''),
|
|
type: self::nullableString($row['type'] ?? null),
|
|
startDate: self::nullableString($row['start_date'] ?? null),
|
|
endDate: self::nullableString($row['end_date'] ?? null),
|
|
returnDate: self::nullableString($row['return_date'] ?? null),
|
|
days: isset($row['days']) && $row['days'] !== '' ? (int) $row['days'] : null,
|
|
status: self::nullableString($row['status'] ?? null),
|
|
reason: self::nullableString($row['reason'] ?? null),
|
|
);
|
|
}
|
|
|
|
private static function nullableString(mixed $value): ?string
|
|
{
|
|
if ($value === null || $value === '') {
|
|
return null;
|
|
}
|
|
|
|
return (string) $value;
|
|
}
|
|
}
|