<?php
declare(strict_types=1);
namespace Slivki\Dto\Settings;
use JsonSerializable;
use OpenApi\Annotations as OA;
final class SortSettingsDto implements JsonSerializable
{
/**
* @OA\Property(
* description="Список сортировок",
* type="array",
* @OA\Items(
* type="object",
* @OA\Property(property="field", type="string", description="Название поля", example="default"),
* @OA\Property(property="direction", type="string", description="Направление", example="asc"),
* @OA\Property(property="name", type="string", description="Название сортировки", example="по умолчанию"),
* ),
* )
*/
private array $sorts;
/**
* @OA\Property(
* property="defaultSort",
* description="Сортировка по умолчанию",
* example="default",
* )
*/
private string $defaultSort;
/**
* @OA\Property(
* property="defaultDirection",
* description="Направление по умолчанию",
* example="asc",
* )
*/
private string $defaultDirection;
public function __construct(array $sorts, string $defaultSort, string $defaultDirection)
{
$this->sorts = $sorts;
$this->defaultSort = $defaultSort;
$this->defaultDirection = $defaultDirection;
}
public function jsonSerialize(): array
{
return [
'sorts' => $this->sorts,
'defaultSort' => $this->defaultSort,
'defaultDirection' => $this->defaultDirection,
];
}
}