Files
hr/app/DTOs/Import/ReportRowDto.php
2026-07-30 17:24:40 +05:00

40 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\DTOs\Import;
readonly class ReportRowDto
{
public function __construct(
public string $employeeNumber,
public ?string $reportDate,
public ?string $title,
public ?string $description,
public ?string $severity,
) {}
/**
* @param array<string, mixed> $row
*/
public static function fromMappedRow(array $row): self
{
return new self(
employeeNumber: (string) ($row['employee_number'] ?? ''),
reportDate: self::nullableString($row['report_date'] ?? null),
title: self::nullableString($row['title'] ?? null),
description: self::nullableString($row['description'] ?? null),
severity: self::nullableString($row['severity'] ?? null),
);
}
private static function nullableString(mixed $value): ?string
{
if ($value === null || $value === '') {
return null;
}
return (string) $value;
}
}