GpsCoordinate.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\ApiResources\Utils;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use ApiPlatform\Metadata\Link;
  6. use ApiPlatform\Metadata\GetCollection;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\ApiProperty;
  9. use App\ApiResources\ApiResourcesInterface;
  10. use App\State\Provider\Utils\GpsCoordinateSearchingProvider;
  11. /**
  12. * Classe resource qui contient les champs de recherche des coordonnées GPS d'une adresse
  13. */
  14. #[ApiResource(
  15. provider: GpsCoordinateSearchingProvider::class,
  16. operations: [
  17. new Get(uriTemplate: '/gps-coordinate-reverse/{latitude}/{longitude}'),
  18. new GetCollection(uriTemplate: '/gps-coordinate-searching')
  19. ]
  20. )]
  21. class GpsCoordinate implements ApiResourcesInterface
  22. {
  23. #[ApiProperty(identifier: true)]
  24. private float $latitude;
  25. #[ApiProperty(identifier: true)]
  26. private float $longitude;
  27. private ?string $streetAddress = null;
  28. private ?string $streetAddressSecond = null;
  29. private ?string $streetAddressThird = null;
  30. private ?string $cp = null;
  31. private ?string $city = null;
  32. private ?string $country = null;
  33. public function __construct()
  34. {
  35. $this->setLatitude(0.0);
  36. $this->setLongitude(0.0);
  37. }
  38. public function setLatitude(?float $latitude): self
  39. {
  40. $this->latitude = $latitude;
  41. return $this;
  42. }
  43. public function getLatitude(): ?float
  44. {
  45. return $this->latitude;
  46. }
  47. public function getLongitude(): ?float
  48. {
  49. return $this->longitude;
  50. }
  51. public function setLongitude(?float $longitude): self
  52. {
  53. $this->longitude = $longitude;
  54. return $this;
  55. }
  56. public function getStreetAddress(): ?string
  57. {
  58. return $this->streetAddress;
  59. }
  60. public function setStreetAddress(?string $streetAddress): self
  61. {
  62. $this->streetAddress = $streetAddress;
  63. return $this;
  64. }
  65. public function getStreetAddressSecond(): ?string
  66. {
  67. return $this->streetAddressSecond;
  68. }
  69. public function setStreetAddressSecond(?string $streetAddressSecond): self
  70. {
  71. $this->streetAddressSecond = $streetAddressSecond;
  72. return $this;
  73. }
  74. public function getStreetAddressThird(): ?string
  75. {
  76. return $this->streetAddressThird;
  77. }
  78. public function setStreetAddressThird(?string $streetAddressThird): self
  79. {
  80. $this->streetAddressThird = $streetAddressThird;
  81. return $this;
  82. }
  83. public function getCp(): ?string
  84. {
  85. return $this->cp;
  86. }
  87. public function setCp(?string $cp): self
  88. {
  89. $this->cp = $cp;
  90. return $this;
  91. }
  92. public function getCity(): ?string
  93. {
  94. return $this->city;
  95. }
  96. public function setCity(?string $city): self
  97. {
  98. $this->city = $city;
  99. return $this;
  100. }
  101. public function getCountry(): ?string
  102. {
  103. return $this->country;
  104. }
  105. public function setCountry(?string $country): self
  106. {
  107. $this->country = $country;
  108. return $this;
  109. }
  110. }