41 lines
812 B
PHP
41 lines
812 B
PHP
|
<?php
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace App\ServiceResults;
|
||
|
|
||
|
use App\Contracts\ServiceResultError as ServiceResultErrorContract;
|
||
|
|
||
|
final class ServiceResultError extends ServiceResult implements ServiceResultErrorContract
|
||
|
{
|
||
|
public function __construct(
|
||
|
private readonly string $message,
|
||
|
private readonly array $errors = [],
|
||
|
private readonly ?int $code = null,
|
||
|
) {
|
||
|
|
||
|
}
|
||
|
|
||
|
public function getMessage(): string
|
||
|
{
|
||
|
return $this->message;
|
||
|
}
|
||
|
|
||
|
public function getCode(): ?int
|
||
|
{
|
||
|
return $this->code;
|
||
|
}
|
||
|
|
||
|
public function getErrors(): array
|
||
|
{
|
||
|
return $this->errors;
|
||
|
}
|
||
|
|
||
|
public function getData(): array
|
||
|
{
|
||
|
return [
|
||
|
'message' => $this->getMessage(),
|
||
|
'errors' => $this->errors
|
||
|
];
|
||
|
}
|
||
|
}
|