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\Playback;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Uxmp\Core\Api\AbstractApiApplication;
use Uxmp\Core\Api\Lib\Message\JsonEnabledResponseInterface;
use Uxmp\Core\Api\Lib\ResultItemFactoryInterface;
use Uxmp\Core\Orm\Repository\PlaybackHistoryRepositoryInterface;
final class PlaybackHistoryApplication extends AbstractApiApplication
{
/**
* @var int
*/
private const HISTORY_LIMIT = 15;
public function __construct(
private readonly PlaybackHistoryRepositoryInterface $playbackHistoryRepository,
private readonly ResultItemFactoryInterface $resultItemFactory,
) {
}
protected function run(
ServerRequestInterface $request,
JsonEnabledResponseInterface $response,
array $args
): ResponseInterface {
$history = $this->playbackHistoryRepository->findBy(
[],
['play_date' => 'DESC'],
self::HISTORY_LIMIT
);
$result = [];
foreach ($history as $item) {
$result[] = $this->resultItemFactory->createPlaybackHistoryItem($item);
return $response->withJson(
['items' => $result],