src/Response/Offer/Location/OfferLocationResponse.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Response\Offer\Location;
  4. use JsonSerializable;
  5. use OpenApi\Annotations as OA;
  6. use Slivki\ValueObject\Coordinate;
  7. use function sprintf;
  8. final class OfferLocationResponse implements JsonSerializable
  9. {
  10.     /**
  11.      * @OA\Property(
  12.      *     property="phoneNumbers",
  13.      *     type="array",
  14.      *     @OA\Items(
  15.      *         type="string",
  16.      *     ),
  17.      *     description="Номера телефонов",
  18.      * ),
  19.      *
  20.      * @var array
  21.      */
  22.     private array $phoneNumbers;
  23.     /**
  24.      * @OA\Property(
  25.      *     property="coordinate",
  26.      *     type="string",
  27.      *     description="Геолокация",
  28.      * ),
  29.      *
  30.      * @var Coordinate
  31.      */
  32.     private Coordinate $coordinate;
  33.     /**
  34.      * @OA\Property(
  35.      *     property="address",
  36.      *     type="string",
  37.      *     description="Адрес",
  38.      * ),
  39.      *
  40.      * @var string
  41.      */
  42.     private string $address;
  43.     /**
  44.      * @OA\Property(
  45.      *     property="workingHours",
  46.      *     type="string",
  47.      *     description="Рабочие часы",
  48.      * ),
  49.      *
  50.      * @var string|null
  51.      */
  52.     private ?string $workingHours;
  53.     /**
  54.      * @OA\Property(
  55.      *     property="description",
  56.      *     type="string",
  57.      *     description="Описание",
  58.      * ),
  59.      *
  60.      * @var string|null
  61.      */
  62.     private ?string $description;
  63.     public function __construct(
  64.         array $phoneNumbers,
  65.         Coordinate $coordinate,
  66.         string $address,
  67.         ?string $workingHours,
  68.         ?string $description
  69.     ) {
  70.         $this->phoneNumbers $phoneNumbers;
  71.         $this->coordinate $coordinate;
  72.         $this->address $address;
  73.         $this->workingHours $workingHours;
  74.         $this->description $description;
  75.     }
  76.     public function getCoordinate(): Coordinate
  77.     {
  78.         return $this->coordinate;
  79.     }
  80.     public function jsonSerialize(): array
  81.     {
  82.         return [
  83.             'phoneNumbers' => $this->phoneNumbers,
  84.             'geoLocation' => [sprintf('%s,%s'$this->coordinate->getLatitude(), $this->coordinate->getLongitude())],
  85.             'address' => $this->address,
  86.             'workingHours' => $this->workingHours,
  87.             'description' => $this->description,
  88.         ];
  89.     }
  90. }