Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GetErrorLogAction | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\SuperAdmin; |
| 6 | |
| 7 | use App\Domain\ErrorLog\Service\ErrorLogService; |
| 8 | use App\Domain\Exception\NotFoundException; |
| 9 | use App\Renderer\JsonRenderer; |
| 10 | use Psr\Http\Message\ResponseInterface; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | |
| 13 | /** |
| 14 | * Get a single error log by ID. |
| 15 | */ |
| 16 | final readonly class GetErrorLogAction |
| 17 | { |
| 18 | public function __construct( |
| 19 | private ErrorLogService $errorLogService, |
| 20 | private JsonRenderer $renderer |
| 21 | ) {} |
| 22 | |
| 23 | /** |
| 24 | * @param array<string, string> $args |
| 25 | * @param ServerRequestInterface $request |
| 26 | * @param ResponseInterface $response |
| 27 | */ |
| 28 | public function __invoke( |
| 29 | ServerRequestInterface $request, |
| 30 | ResponseInterface $response, |
| 31 | array $args |
| 32 | ): ResponseInterface { |
| 33 | $errorId = (int)$args['id']; |
| 34 | |
| 35 | $error = $this->errorLogService->getById($errorId); |
| 36 | |
| 37 | if ($error === null) { |
| 38 | throw new NotFoundException("Error log with ID {$errorId} not found"); |
| 39 | } |
| 40 | |
| 41 | return $this->renderer->json($response, [ |
| 42 | 'success' => true, |
| 43 | 'data' => $error, |
| 44 | ]); |
| 45 | } |
| 46 | } |