for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Uxmp\Core\Api\RadioStation;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Teapot\StatusCode\Http;
use Uxmp\Core\Api\AbstractApiApplication;
use Uxmp\Core\Api\Lib\Message\JsonEnabledResponseInterface;
use Uxmp\Core\Orm\Repository\RadioStationRepositoryInterface;
/**
* Retrieves a radio station
*/
final class RadioStationRetrieveApplication extends AbstractApiApplication
{
public function __construct(
private readonly RadioStationRepositoryInterface $radioStationRepository,
) {
}
protected function run(
ServerRequestInterface $request,
JsonEnabledResponseInterface $response,
array $args
): ResponseInterface {
$stationId = (int) ($args['stationId'] ?? 0);
$station = $this->radioStationRepository->find($stationId);
if ($station === null) {
return $response->withStatus(Http::NOT_FOUND);
return $response->withJson([
'id' => $station->getId(),
'name' => $station->getName(),
'url' => $station->getUrl(),
]);