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\Art;
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\Art\ArtItemIdentifierInterface;
use Uxmp\Core\Component\Art\CachedArtResponseProviderInterface;
final class ArtApplication extends AbstractApiApplication
{
public function __construct(
private readonly CachedArtResponseProviderInterface $cachedArtResponseProvider,
private readonly ArtItemIdentifierInterface $artItemIdentifier,
) {
}
protected function run(
ServerRequestInterface $request,
JsonEnabledResponseInterface $response,
array $args
): ResponseInterface {
$item = $this->artItemIdentifier->identify(
sprintf(
'%s-%d',
$args['type'] ?? '',
$args['id'] ?? 0
)
);
if ($item === null) {
return $response->withStatus(Http::NOT_FOUND);
return $this->cachedArtResponseProvider->withCachedArt($response, $item);