src/Dto/Settings/SortSettingsDto.php line 10

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Dto\Settings;
  4. use JsonSerializable;
  5. use OpenApi\Annotations as OA;
  6. final class SortSettingsDto implements JsonSerializable
  7. {
  8.     /**
  9.      * @OA\Property(
  10.      *     description="Список сортировок",
  11.      *     type="array",
  12.      *     @OA\Items(
  13.      *          type="object",
  14.      *          @OA\Property(property="field", type="string", description="Название поля", example="default"),
  15.      *          @OA\Property(property="direction", type="string", description="Направление", example="asc"),
  16.      *          @OA\Property(property="name", type="string", description="Название сортировки", example="по умолчанию"),
  17.      *     ),
  18.      * )
  19.      */
  20.     private array $sorts;
  21.     /**
  22.      * @OA\Property(
  23.      *     property="defaultSort",
  24.      *     description="Сортировка по умолчанию",
  25.      *     example="default",
  26.      * )
  27.      */
  28.     private string $defaultSort;
  29.     /**
  30.      * @OA\Property(
  31.      *     property="defaultDirection",
  32.      *     description="Направление по умолчанию",
  33.      *     example="asc",
  34.      * )
  35.      */
  36.     private string $defaultDirection;
  37.     public function __construct(array $sortsstring $defaultSortstring $defaultDirection)
  38.     {
  39.         $this->sorts $sorts;
  40.         $this->defaultSort $defaultSort;
  41.         $this->defaultDirection $defaultDirection;
  42.     }
  43.     public function jsonSerialize(): array
  44.     {
  45.         return [
  46.             'sorts' => $this->sorts,
  47.             'defaultSort' => $this->defaultSort,
  48.             'defaultDirection' => $this->defaultDirection,
  49.         ];
  50.     }
  51. }