2025-01-23 00:45:59 +01:00

42 lines
904 B
PHP

<?php
declare(strict_types=1);
namespace App\Services\QueryRequestModifiers\Comment;
use App\Services\QueryRequestModifiers\OrderableDTO;
use App\Services\QueryRequestModifiers\SortDirection;
/**
* @implements OrderableDTO<CommentOrderDTO>
*/
readonly class CommentOrderDTO implements OrderableDTO
{
public function __construct(public string $column, public SortDirection $direction)
{
}
public function toCacheKey(): string
{
return $this->column . '|' . $this->direction->value;
}
public function getColumn(): string
{
return $this->column;
}
public function getDirection(): SortDirection
{
return $this->direction;
}
public static function createFromValues(string $column, SortDirection $sortDirection): OrderableDTO
{
return new self(
$column,
$sortDirection
);
}
}