src/BusinessFeature/Yclients/Dto/StaffDto.php line 9

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\BusinessFeature\Yclients\Dto;
  4. use OpenApi\Annotations as OA;
  5. use Nelmio\ApiDocBundle\Annotation\Model;
  6. use JsonSerializable;
  7. final class StaffDto implements JsonSerializable
  8. {
  9.     /**
  10.      * @OA\Property(
  11.      *     property="id",
  12.      *     type="integer",
  13.      *     description="ID сотрудника",
  14.      *     example=12345
  15.      * )
  16.      */
  17.     private int $id;
  18.     /**
  19.      * @OA\Property(
  20.      *     property="name",
  21.      *     type="string",
  22.      *     description="Имя сотрудника",
  23.      *     example="Иван Иванов"
  24.      * )
  25.      */
  26.     private string $name;
  27.     /**
  28.      * @OA\Property(
  29.      *     property="rating",
  30.      *     type="number",
  31.      *     format="float",
  32.      *     description="Рейтинг сотрудника",
  33.      *     example=4.5
  34.      * )
  35.      */
  36.     private float $rating;
  37.     /**
  38.      * @OA\Property(
  39.      *     property="avatar",
  40.      *     type="string",
  41.      *     description="URL аватара сотрудника",
  42.      *     example="https://example.com/avatar.jpg"
  43.      * )
  44.      */
  45.     private string $avatar;
  46.     /**
  47.      * @OA\Property(
  48.      *     property="specialization",
  49.      *     type="string",
  50.      *     description="Специализация сотрудника",
  51.      *     example="Парикмахер"
  52.      * )
  53.      */
  54.     private string $specialization;
  55.     /**
  56.      * @OA\Property(
  57.      *     property="external_link",
  58.      *     type="string",
  59.      *     description="Внешняя ссылка на профиль сотрудника",
  60.      *     example="https://example.com/staff/12345"
  61.      * )
  62.      */
  63.     private ?string $externalLink;
  64.     /**
  65.      * @OA\Property(
  66.      *     property="images",
  67.      *     type="object",
  68.      *     ref=@Model(type=ImagesDto::class),
  69.      *     description="Изображения сотрудника"
  70.      * )
  71.      */
  72.     private ?ImagesDto $images;
  73.     public function __construct(
  74.         int $id,
  75.         string $name,
  76.         float $rating,
  77.         string $avatar,
  78.         string $specialization,
  79.         ?string $externalLink,
  80.         ?ImagesDto $images
  81.     ) {
  82.         $this->id $id;
  83.         $this->name $name;
  84.         $this->rating $rating;
  85.         $this->avatar $avatar;
  86.         $this->specialization $specialization;
  87.         $this->externalLink $externalLink;
  88.         $this->images $images;
  89.     }
  90.     public function jsonSerialize(): array
  91.     {
  92.         return [
  93.             'id' => $this->id,
  94.             'name' => $this->name,
  95.             'rating' => $this->rating,
  96.             'avatar' => $this->avatar,
  97.             'specialization' => $this->specialization,
  98.             'external_link' => $this->externalLink,
  99.             'images' => $this->images,
  100.         ];
  101.     }
  102. }