29 lines
594 B
PHP
29 lines
594 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Domain\Models\ValueObjects;
|
|
|
|
/**
|
|
* @template T
|
|
*/
|
|
final readonly class ImportRowResult
|
|
{
|
|
/**
|
|
* @param T|null $mappedResult
|
|
*/
|
|
public function __construct(
|
|
public int $lineNumber,
|
|
public mixed $mappedResult = null,
|
|
public ?string $error = null
|
|
) {
|
|
if ($lineNumber <= 0) {
|
|
throw new \DomainException('Line number must be a positive integer.');
|
|
}
|
|
}
|
|
|
|
public function isSuccess(): bool
|
|
{
|
|
return $this->mappedResult !== null && $this->error === null;
|
|
}
|
|
}
|