ldc-arcadia-api/src/Presentation/Api/V1/Http/Controllers/Employees/EmployeeShowController.php
Jérémy Munsch 91114cb67b
feat(inco-compositions): add IncoCompositionShow feature
- Implemented IncoCompositionShowController to handle requests for inco composition details.
- Created IncoCompositionDto for response data structure.
- Added IncoCompositionShowRequest for request validation.
- Developed IncoCompositionShowResponse for formatting API responses.
- Introduced IncoCompositionShowPresenter and IncoCompositionShowView for presentation logic.
- Added tests for IncoCompositionShow feature and OpenAPI conformance.
2026-08-14 15:56:58 +02:00

45 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Presentation\Api\V1\Http\Controllers\Employees;
use Application\Usecase\Employees\Find\FindEmployee;
use Application\Usecase\Employees\Find\Input;
use Presentation\Api\V1\Contracts\ApiResponse;
use Presentation\Api\V1\Http\Requests\Employees\EmployeeShowRequest;
use Presentation\Api\V1\Http\Responses\Employees\EmployeeShowResponse;
use Presentation\Api\V1\Presenters\Employees\EmployeeShowPresenter;
use Shared\DDD\Usecase\Builder\UsecaseBuilder;
use Shared\DDD\Usecase\Builder\UsecaseExecutor;
final readonly class EmployeeShowController
{
/** @param UsecaseExecutor<\Shared\DDD\Usecase\Input, \Shared\DDD\Usecase\Output> $executor */
public function __construct(
private FindEmployee $usecase,
private UsecaseExecutor $executor,
private EmployeeShowPresenter $presenter,
) {
}
public function __invoke(EmployeeShowRequest $request): ApiResponse
{
$input = $this->inputFrom($request);
$response = UsecaseBuilder::using($this->executor)
->do($this->usecase)
->from($input)
->with($this->presenter)
->run();
return new EmployeeShowResponse($response);
}
private function inputFrom(EmployeeShowRequest $request): Input
{
return new Input(
id: $request->employeeId(),
);
}
}