geocoder-php /
here-provider
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | /* |
||||
| 6 | * This file is part of the Geocoder package. |
||||
| 7 | * For the full copyright and license information, please view the LICENSE |
||||
| 8 | * file that was distributed with this source code. |
||||
| 9 | * |
||||
| 10 | * @license MIT License |
||||
| 11 | */ |
||||
| 12 | |||||
| 13 | namespace Geocoder\Provider\Here\Model; |
||||
| 14 | |||||
| 15 | use Geocoder\Model\Address; |
||||
| 16 | |||||
| 17 | /** |
||||
| 18 | * @author sébastien Barré <[email protected]> |
||||
| 19 | */ |
||||
| 20 | final class HereAddress extends Address |
||||
| 21 | { |
||||
| 22 | /** |
||||
| 23 | * @var string|null |
||||
| 24 | */ |
||||
| 25 | private $locationId; |
||||
| 26 | |||||
| 27 | /** |
||||
| 28 | * @var string|null |
||||
| 29 | */ |
||||
| 30 | private $locationType; |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * @var string|null |
||||
| 34 | */ |
||||
| 35 | private $locationName; |
||||
| 36 | |||||
| 37 | /** |
||||
| 38 | * @var array|null |
||||
| 39 | */ |
||||
| 40 | private $additionalData; |
||||
| 41 | |||||
| 42 | /** |
||||
| 43 | * @var array|null |
||||
| 44 | */ |
||||
| 45 | private $shape; |
||||
| 46 | |||||
| 47 | /** |
||||
| 48 | * @return string|null |
||||
| 49 | */ |
||||
| 50 | public function getLocationId() |
||||
| 51 | { |
||||
| 52 | return $this->locationId; |
||||
| 53 | } |
||||
| 54 | |||||
| 55 | /** |
||||
| 56 | * @param string|null $LocationId |
||||
| 57 | * |
||||
| 58 | * @return HereAddress |
||||
| 59 | */ |
||||
| 60 | public function withLocationId(string $locationId = null): self |
||||
| 61 | { |
||||
| 62 | $new = clone $this; |
||||
| 63 | $new->locationId = $locationId; |
||||
| 64 | |||||
| 65 | return $new; |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | /** |
||||
| 69 | * @return string|null |
||||
| 70 | */ |
||||
| 71 | public function getLocationType() |
||||
| 72 | { |
||||
| 73 | return $this->locationType; |
||||
| 74 | } |
||||
| 75 | |||||
| 76 | /** |
||||
| 77 | * @param string|null $LocationType |
||||
| 78 | * |
||||
| 79 | * @return HereAddress |
||||
| 80 | */ |
||||
| 81 | public function withLocationType(string $locationType = null): self |
||||
| 82 | { |
||||
| 83 | $new = clone $this; |
||||
| 84 | $new->locationType = $locationType; |
||||
| 85 | |||||
| 86 | return $new; |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | /** |
||||
| 90 | * @return string|null |
||||
| 91 | */ |
||||
| 92 | public function getLocationName() |
||||
| 93 | { |
||||
| 94 | return $this->locationName; |
||||
| 95 | } |
||||
| 96 | |||||
| 97 | /** |
||||
| 98 | * @param string|null $LocationName |
||||
| 99 | * |
||||
| 100 | * @return HereAddress |
||||
| 101 | */ |
||||
| 102 | public function withLocationName(string $locationName = null): self |
||||
| 103 | { |
||||
| 104 | $new = clone $this; |
||||
| 105 | $new->locationName = $locationName; |
||||
| 106 | |||||
| 107 | return $new; |
||||
| 108 | } |
||||
| 109 | |||||
| 110 | /** |
||||
| 111 | * @return array|null |
||||
| 112 | */ |
||||
| 113 | public function getAdditionalData() |
||||
| 114 | { |
||||
| 115 | return $this->additionalData; |
||||
| 116 | } |
||||
| 117 | |||||
| 118 | /** |
||||
| 119 | * @param array|null $additionalData |
||||
| 120 | * |
||||
| 121 | * @return HereAddress |
||||
| 122 | */ |
||||
| 123 | public function withAdditionalData(array $additionalData = null): self |
||||
| 124 | { |
||||
| 125 | $new = clone $this; |
||||
| 126 | |||||
| 127 | foreach ($additionalData as $data) { |
||||
| 128 | $new = $new->addAdditionalData($data['key'], $data['value']); |
||||
| 129 | } |
||||
| 130 | |||||
| 131 | return $new; |
||||
| 132 | } |
||||
| 133 | |||||
| 134 | /** |
||||
| 135 | * @param string $name |
||||
| 136 | * @param mixed|null $value |
||||
| 137 | * |
||||
| 138 | * @return HereAddress |
||||
| 139 | */ |
||||
| 140 | public function addAdditionalData(string $name, $value = null): self |
||||
| 141 | { |
||||
| 142 | $new = clone $this; |
||||
| 143 | $new->additionalData[$name] = $value; |
||||
| 144 | |||||
| 145 | return $new; |
||||
| 146 | } |
||||
| 147 | |||||
| 148 | /** |
||||
| 149 | * @param string $name |
||||
| 150 | * @param mixed|null $default |
||||
| 151 | * |
||||
| 152 | * @return mixed |
||||
| 153 | */ |
||||
| 154 | public function getAdditionalDataValue(string $name, $default = null) |
||||
| 155 | { |
||||
| 156 | if ($this->hasAdditionalDataValue($name)) { |
||||
| 157 | return $this->additionalData[$name]; |
||||
| 158 | } |
||||
| 159 | |||||
| 160 | return $default; |
||||
| 161 | } |
||||
| 162 | |||||
| 163 | /** |
||||
| 164 | * @param string $name |
||||
| 165 | * |
||||
| 166 | * @return bool |
||||
| 167 | */ |
||||
| 168 | public function hasAdditionalDataValue(string $name): bool |
||||
| 169 | { |
||||
| 170 | return array_key_exists($name, $this->additionalData); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 171 | } |
||||
| 172 | |||||
| 173 | /** |
||||
| 174 | * @param array|null $shape |
||||
| 175 | * |
||||
| 176 | * @return HereAddress |
||||
| 177 | */ |
||||
| 178 | public function withShape(array $shape = null): self |
||||
| 179 | { |
||||
| 180 | $new = clone $this; |
||||
| 181 | |||||
| 182 | if (!empty($shape)) { |
||||
| 183 | foreach ($shape as $key => $data) { |
||||
| 184 | $new = $new->addShape($key, $data); |
||||
| 185 | } |
||||
| 186 | } |
||||
| 187 | |||||
| 188 | return $new; |
||||
| 189 | } |
||||
| 190 | |||||
| 191 | /** |
||||
| 192 | * @param string $name |
||||
| 193 | * @param mixed|null $value |
||||
| 194 | * |
||||
| 195 | * @return HereAddress |
||||
| 196 | */ |
||||
| 197 | public function addShape(string $name, $value = null): self |
||||
| 198 | { |
||||
| 199 | $new = clone $this; |
||||
| 200 | $new->shape[$name] = $value; |
||||
| 201 | |||||
| 202 | return $new; |
||||
| 203 | } |
||||
| 204 | |||||
| 205 | public function getShapeValue(string $name, $default = null) |
||||
| 206 | { |
||||
| 207 | if ($this->hasShapeValue($name)) { |
||||
| 208 | return $this->shape[$name]; |
||||
| 209 | } |
||||
| 210 | |||||
| 211 | return $default; |
||||
| 212 | } |
||||
| 213 | |||||
| 214 | /** |
||||
| 215 | * @param string $name |
||||
| 216 | * |
||||
| 217 | * @return bool |
||||
| 218 | */ |
||||
| 219 | public function hasShapeValue(string $name): bool |
||||
| 220 | { |
||||
| 221 | return array_key_exists($name, $this->shape); |
||||
|
0 ignored issues
–
show
It seems like
$this->shape can also be of type null; however, parameter $search of array_key_exists() does only seem to accept array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 222 | } |
||||
| 223 | } |
||||
| 224 |