Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| VersionAction | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Home; |
| 6 | |
| 7 | use App\Renderer\JsonRenderer; |
| 8 | use Psr\Http\Message\ResponseInterface; |
| 9 | use Psr\Http\Message\ServerRequestInterface; |
| 10 | |
| 11 | /** |
| 12 | * GET /api/version |
| 13 | * |
| 14 | * Returns the application version read from the VERSION file. |
| 15 | * Public endpoint — no authentication required. |
| 16 | */ |
| 17 | final readonly class VersionAction |
| 18 | { |
| 19 | public function __construct( |
| 20 | private JsonRenderer $renderer, |
| 21 | ) {} |
| 22 | |
| 23 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface |
| 24 | { |
| 25 | $versionFile = __DIR__ . '/../../../../VERSION'; |
| 26 | $version = is_file($versionFile) ? trim((string)file_get_contents($versionFile)) : 'unknown'; |
| 27 | |
| 28 | return $this->renderer->json($response, [ |
| 29 | 'success' => true, |
| 30 | 'data' => ['version' => $version], |
| 31 | ]); |
| 32 | } |
| 33 | } |