Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ListErrorLogsAction | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\SuperAdmin; |
| 6 | |
| 7 | use App\Domain\ErrorLog\Data\ErrorLogFilterData; |
| 8 | use App\Domain\ErrorLog\Service\ErrorLogService; |
| 9 | use App\Renderer\JsonRenderer; |
| 10 | use Psr\Http\Message\ResponseInterface; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | |
| 13 | /** |
| 14 | * List error logs with filtering and pagination. |
| 15 | */ |
| 16 | final readonly class ListErrorLogsAction |
| 17 | { |
| 18 | private ErrorLogService $errorLogService; |
| 19 | |
| 20 | private JsonRenderer $renderer; |
| 21 | |
| 22 | public function __construct(ErrorLogService $errorLogService, JsonRenderer $renderer) |
| 23 | { |
| 24 | $this->errorLogService = $errorLogService; |
| 25 | $this->renderer = $renderer; |
| 26 | } |
| 27 | |
| 28 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
| 29 | { |
| 30 | $params = $request->getQueryParams(); |
| 31 | $filter = new ErrorLogFilterData($params); |
| 32 | |
| 33 | $result = $this->errorLogService->list($filter); |
| 34 | |
| 35 | return $this->renderer->json($response, [ |
| 36 | 'success' => true, |
| 37 | 'data' => [ |
| 38 | 'errors' => $result['data'], |
| 39 | 'pagination' => [ |
| 40 | 'total' => $result['total'], |
| 41 | 'page' => $result['page'], |
| 42 | 'limit' => $result['limit'], |
| 43 | 'totalPages' => (int)ceil($result['total'] / $result['limit']), |
| 44 | ], |
| 45 | 'summary' => [ |
| 46 | 'countsByLevel' => $result['countsByLevel'], |
| 47 | 'unresolvedCount' => $result['unresolvedCount'], |
| 48 | ], |
| 49 | 'logLevels' => $this->errorLogService->getLogLevels(), |
| 50 | ], |
| 51 | ]); |
| 52 | } |
| 53 | } |