src/Dto/OnlineOrder/OrderItemDto.php line 10

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Dto\OnlineOrder;
  4. use JsonSerializable;
  5. use OpenApi\Annotations as OA;
  6. final class OrderItemDto implements JsonSerializable
  7. {
  8.     /**
  9.      * @OA\Property(
  10.      *     property="name",
  11.      *     description="Название",
  12.      *     example="Пицца Маргарита",
  13.      * )
  14.      */
  15.     private string $name;
  16.     /**
  17.      * @OA\Property(
  18.      *     property="quantity",
  19.      *     description="Количество",
  20.      *     example="1",
  21.      * )
  22.      */
  23.     private int $quantity;
  24.     /**
  25.      * @OA\Property(
  26.      *     property="purchasePrice",
  27.      *     type="number",
  28.      *     format="float",
  29.      *     description="Цена (BYN)",
  30.      *     example="10.50",
  31.      * )
  32.      */
  33.     private float $purchasePrice;
  34.     public function __construct(string $nameint $quantityfloat $purchasePrice)
  35.     {
  36.         $this->name $name;
  37.         $this->quantity $quantity;
  38.         $this->purchasePrice $purchasePrice;
  39.     }
  40.     public function getName(): string
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function getQuantity(): int
  45.     {
  46.         return $this->quantity;
  47.     }
  48.     public function getPurchasePrice(): float
  49.     {
  50.         return $this->purchasePrice;
  51.     }
  52.     public function jsonSerialize(): array
  53.     {
  54.         return [
  55.             'name' => $this->name,
  56.             'quantity' => $this->quantity,
  57.             'purchasePrice' => $this->purchasePrice,
  58.         ];
  59.     }
  60. }