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\Artist;
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\Component\Config\ConfigProviderInterface;
use Uxmp\Core\Orm\Repository\ArtistRepositoryInterface;
final class ArtistApplication extends AbstractApiApplication
{
public function __construct(
private readonly ArtistRepositoryInterface $artistRepository,
private readonly ConfigProviderInterface $config
) {
}
protected function run(
ServerRequestInterface $request,
JsonEnabledResponseInterface $response,
array $args
): ResponseInterface {
$artistId = (int) ($args['artistId'] ?? 0);
$artist = $this->artistRepository->find($artistId);
if ($artist === null) {
return $response->withStatus(Http::NOT_FOUND);
return $response->withJson(
[
'id' => $artistId,
'name' => $artist->getTitle(),
'cover' => sprintf('%s/art/artist/%d', $this->config->getBaseUrl(), $artistId),
'mbId' => $artist->getMbid(),
]
);