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\Settings;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Teapot\StatusCode\Http;
use Uxmp\Core\Api\Lib\Message\JsonEnabledResponseInterface;
use Uxmp\Core\Api\Lib\ResultItemFactoryInterface;
use Uxmp\Core\Component\User\PrivilegeCheckerInterface;
use Uxmp\Core\Orm\Repository\UserRepositoryInterface;
/**
* User retrieval
*/
final class UserRetrieveApplication extends AbstractSettingsApplication
{
public function __construct(
private readonly UserRepositoryInterface $userRepository,
PrivilegeCheckerInterface $privilegeChecker,
private readonly ResultItemFactoryInterface $resultItemFactory,
) {
parent::__construct(
$privilegeChecker
);
}
* @param array<string, scalar> $args
protected function serve(
ServerRequestInterface $request,
JsonEnabledResponseInterface $response,
array $args
): ResponseInterface {
$user = $this->userRepository->find((int) ($args['userId'] ?? 0));
if ($user === null) {
return $response->withStatus(Http::NOT_FOUND);
return $response->withJson(
$this->resultItemFactory->createUserListItem($user)