Skip to content

Commit

Permalink
Code revision
Browse files Browse the repository at this point in the history
  • Loading branch information
xsga committed Sep 20, 2024
1 parent 19dc434 commit 187def7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Xsga\FilmAffinityApi\Modules\Errors\Application\Services\GetAllErrorsService;
use Xsga\FilmAffinityApi\Modules\Errors\Infrastructure\Controllers\Mappers\ErrorDtoToErrorResponse;
use Xsga\FilmAffinityApi\Modules\Shared\Api\Infrastructure\Controllers\AbstractController;

final class GetAllErrorsController extends AbstractController
{
public function __construct(
private GetAllErrorsService $getAllErrorsService,
private ErrorDtoToErrorResponse $mapper
) {
public function __construct(private GetAllErrorsService $getAllErrorsService)
{
}

public function __invoke(Request $request, Response $response): Response
{
$errorsDto = $this->getAllErrorsService->get();

return $this->writeResponse($response, $this->mapper->convertArray($errorsDto));
return $this->writeResponse($response, $errorsDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Xsga\FilmAffinityApi\Modules\Errors\Application\Services\GetErrorService;
use Xsga\FilmAffinityApi\Modules\Errors\Infrastructure\Controllers\Mappers\ErrorDtoToErrorResponse;
use Xsga\FilmAffinityApi\Modules\Shared\Api\Infrastructure\Controllers\AbstractController;

final class GetErrorController extends AbstractController
{
public function __construct(
private GetErrorService $getErrorService,
private ErrorDtoToErrorResponse $mapper
) {
public function __construct(private GetErrorService $getErrorService)
{
}

public function __invoke(Request $request, Response $response, array $args): Response
{
$errorDto = $this->getErrorService->get((int)$args['id']);

return $this->writeResponse($response, $this->mapper->convert($errorDto));
return $this->writeResponse($response, $errorDto);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

final class SimpleSearchController extends AbstractController
{
private string $schema = 'simple.search.schema';
private const string SCHEMA_NAME = 'simple.search.schema';

public function __construct(
private SimpleSearchService $simpleSearchService,
Expand All @@ -22,7 +22,7 @@ public function __construct(

public function __invoke(Request $request, Response $response): Response
{
$this->validateJson((string)$request->getBody(), $this->schema);
$this->validateJson((string)$request->getBody(), self::SCHEMA_NAME);

$searchDto = $this->inputToSearchDto->convert($request->getParsedBody());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@

final class GetTokenController extends AbstractController
{
private const string SCHEMA_NAME = 'get.token.schema';

public function __construct(private GetTokenService $getToken)
{
}

public function __invoke(Request $request, Response $response): Response
{
$this->validateJson((string)$request->getBody(), 'get.token.schema');

$body = $request->getParsedBody();
$this->validateJson((string)$request->getBody(), self::SCHEMA_NAME);

// TODO: custom response.
$token = [];
$token['token'] = $this->getToken->get($body['user'], $body['password']);
$body = (array)$request->getParsedBody();

return $this->writeResponse($response, $token);
return $this->writeResponse($response, $this->getToken->get($body['user'], $body['password']));
}
}

0 comments on commit 187def7

Please sign in to comment.