Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.18% |
89 / 107 |
|
86.05% |
37 / 43 |
CRAP | |
0.00% |
0 / 1 |
| Geolocation | |
83.18% |
89 / 107 |
|
86.05% |
37 / 43 |
101.78 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| openAPITypes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| openAPIFormats | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isNullable | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isNullableSetToNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| attributeMap | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getModelName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| listInvalidProperties | |
55.00% |
11 / 20 |
|
0.00% |
0 / 1 |
51.90 | |||
| valid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAccuracyRadius | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setAccuracyRadius | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| getLatitude | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLatitude | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
3.33 | |||
| getLongitude | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLongitude | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
3.33 | |||
| getPostalCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setPostalCode | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getTimezone | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setTimezone | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getCityName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setCityName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getCountryCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setCountryCode | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
3.33 | |||
| getCountryName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setCountryName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getContinentCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setContinentCode | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
3.33 | |||
| getContinentName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setContinentName | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getSubdivisions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setSubdivisions | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| offsetExists | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| offsetGet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| offsetSet | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| offsetUnset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toHeaderValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| openAPINullables | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOpenAPINullablesSetToNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setOpenAPINullablesSetToNull | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| setIfExists | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Geolocation. |
| 5 | * |
| 6 | * @category Class |
| 7 | * |
| 8 | * @author Fingerprint |
| 9 | * |
| 10 | * @see https://fingerprint.com |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * Server API. |
| 15 | * |
| 16 | * Fingerprint Server API allows you to get, search, and update Events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios. Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device. |
| 17 | * |
| 18 | * The version of the OpenAPI document: 4 |
| 19 | * Contact: support@fingerprint.com |
| 20 | * Generated by: https://openapi-generator.tech |
| 21 | * Generator version: 7.21.0 |
| 22 | */ |
| 23 | |
| 24 | /** |
| 25 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 26 | * https://openapi-generator.tech |
| 27 | * Do not edit the class manually. |
| 28 | */ |
| 29 | |
| 30 | namespace Fingerprint\ServerSdk\Model; |
| 31 | |
| 32 | use Fingerprint\ServerSdk\ObjectSerializer; |
| 33 | |
| 34 | /** |
| 35 | * Geolocation Class. |
| 36 | * |
| 37 | * @category Class |
| 38 | * |
| 39 | * @author Fingerprint |
| 40 | * |
| 41 | * @see https://fingerprint.com |
| 42 | * |
| 43 | * @implements \ArrayAccess<string, mixed> |
| 44 | * |
| 45 | * @noinspection GrazieInspection |
| 46 | * @noinspection RedundantSuppression |
| 47 | */ |
| 48 | class Geolocation implements ModelInterface, \ArrayAccess, \JsonSerializable |
| 49 | { |
| 50 | public const DISCRIMINATOR = null; |
| 51 | |
| 52 | /** |
| 53 | * The original name of the model. |
| 54 | * |
| 55 | */ |
| 56 | protected static string $openAPIModelName = 'Geolocation'; |
| 57 | |
| 58 | /** |
| 59 | * Array of property to type mappings. Used for (de)serialization. |
| 60 | * |
| 61 | * @var string[] |
| 62 | */ |
| 63 | protected static array $openAPITypes = [ |
| 64 | 'accuracy_radius' => 'int', |
| 65 | 'latitude' => 'float', |
| 66 | 'longitude' => 'float', |
| 67 | 'postal_code' => 'string', |
| 68 | 'timezone' => 'string', |
| 69 | 'city_name' => 'string', |
| 70 | 'country_code' => 'string', |
| 71 | 'country_name' => 'string', |
| 72 | 'continent_code' => 'string', |
| 73 | 'continent_name' => 'string', |
| 74 | 'subdivisions' => '\Fingerprint\ServerSdk\Model\GeolocationSubdivisionsInner[]', |
| 75 | ]; |
| 76 | |
| 77 | /** |
| 78 | * Array of property to format mappings. Used for (de)serialization. |
| 79 | * |
| 80 | * @var string[] |
| 81 | * |
| 82 | * @phpstan-var array<string, string|null> |
| 83 | * |
| 84 | * @psalm-var array<string, string|null> |
| 85 | */ |
| 86 | protected static array $openAPIFormats = [ |
| 87 | 'accuracy_radius' => null, |
| 88 | 'latitude' => 'double', |
| 89 | 'longitude' => 'double', |
| 90 | 'postal_code' => null, |
| 91 | 'timezone' => 'timezone', |
| 92 | 'city_name' => null, |
| 93 | 'country_code' => null, |
| 94 | 'country_name' => null, |
| 95 | 'continent_code' => null, |
| 96 | 'continent_name' => null, |
| 97 | 'subdivisions' => null, |
| 98 | ]; |
| 99 | |
| 100 | /** |
| 101 | * Array of nullable properties. Used for (de)serialization. |
| 102 | * |
| 103 | * @var bool[] |
| 104 | */ |
| 105 | protected static array $openAPINullables = [ |
| 106 | 'accuracy_radius' => false, |
| 107 | 'latitude' => false, |
| 108 | 'longitude' => false, |
| 109 | 'postal_code' => false, |
| 110 | 'timezone' => false, |
| 111 | 'city_name' => false, |
| 112 | 'country_code' => false, |
| 113 | 'country_name' => false, |
| 114 | 'continent_code' => false, |
| 115 | 'continent_name' => false, |
| 116 | 'subdivisions' => false, |
| 117 | ]; |
| 118 | |
| 119 | /** |
| 120 | * If a nullable field gets set to null, insert it here. |
| 121 | * |
| 122 | * @var bool[] |
| 123 | */ |
| 124 | protected array $openAPINullablesSetToNull = []; |
| 125 | |
| 126 | /** |
| 127 | * Array of attributes where the key is the local name, |
| 128 | * and the value is the original name. |
| 129 | * |
| 130 | * @var string[] |
| 131 | */ |
| 132 | protected static array $attributeMap = [ |
| 133 | 'accuracy_radius' => 'accuracy_radius', |
| 134 | 'latitude' => 'latitude', |
| 135 | 'longitude' => 'longitude', |
| 136 | 'postal_code' => 'postal_code', |
| 137 | 'timezone' => 'timezone', |
| 138 | 'city_name' => 'city_name', |
| 139 | 'country_code' => 'country_code', |
| 140 | 'country_name' => 'country_name', |
| 141 | 'continent_code' => 'continent_code', |
| 142 | 'continent_name' => 'continent_name', |
| 143 | 'subdivisions' => 'subdivisions', |
| 144 | ]; |
| 145 | |
| 146 | /** |
| 147 | * Array of attributes to setter functions (for deserialization of responses). |
| 148 | * |
| 149 | * @var string[] |
| 150 | */ |
| 151 | protected static array $setters = [ |
| 152 | 'accuracy_radius' => 'setAccuracyRadius', |
| 153 | 'latitude' => 'setLatitude', |
| 154 | 'longitude' => 'setLongitude', |
| 155 | 'postal_code' => 'setPostalCode', |
| 156 | 'timezone' => 'setTimezone', |
| 157 | 'city_name' => 'setCityName', |
| 158 | 'country_code' => 'setCountryCode', |
| 159 | 'country_name' => 'setCountryName', |
| 160 | 'continent_code' => 'setContinentCode', |
| 161 | 'continent_name' => 'setContinentName', |
| 162 | 'subdivisions' => 'setSubdivisions', |
| 163 | ]; |
| 164 | |
| 165 | /** |
| 166 | * Array of attributes to getter functions (for serialization of requests). |
| 167 | * |
| 168 | * @var string[] |
| 169 | */ |
| 170 | protected static array $getters = [ |
| 171 | 'accuracy_radius' => 'getAccuracyRadius', |
| 172 | 'latitude' => 'getLatitude', |
| 173 | 'longitude' => 'getLongitude', |
| 174 | 'postal_code' => 'getPostalCode', |
| 175 | 'timezone' => 'getTimezone', |
| 176 | 'city_name' => 'getCityName', |
| 177 | 'country_code' => 'getCountryCode', |
| 178 | 'country_name' => 'getCountryName', |
| 179 | 'continent_code' => 'getContinentCode', |
| 180 | 'continent_name' => 'getContinentName', |
| 181 | 'subdivisions' => 'getSubdivisions', |
| 182 | ]; |
| 183 | |
| 184 | /** |
| 185 | * Associative array for storing property values. |
| 186 | */ |
| 187 | protected array $container = []; |
| 188 | |
| 189 | /** |
| 190 | * Constructor. |
| 191 | * |
| 192 | * @param array|null $data Associated array of property values |
| 193 | * initializing the model |
| 194 | * |
| 195 | * @noinspection DuplicatedCode |
| 196 | */ |
| 197 | public function __construct(?array $data = null) |
| 198 | { |
| 199 | $this->setIfExists('accuracy_radius', $data ?? [], null); |
| 200 | $this->setIfExists('latitude', $data ?? [], null); |
| 201 | $this->setIfExists('longitude', $data ?? [], null); |
| 202 | $this->setIfExists('postal_code', $data ?? [], null); |
| 203 | $this->setIfExists('timezone', $data ?? [], null); |
| 204 | $this->setIfExists('city_name', $data ?? [], null); |
| 205 | $this->setIfExists('country_code', $data ?? [], null); |
| 206 | $this->setIfExists('country_name', $data ?? [], null); |
| 207 | $this->setIfExists('continent_code', $data ?? [], null); |
| 208 | $this->setIfExists('continent_name', $data ?? [], null); |
| 209 | $this->setIfExists('subdivisions', $data ?? [], null); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Gets the string presentation of the object. |
| 214 | * |
| 215 | */ |
| 216 | public function __toString(): string |
| 217 | { |
| 218 | return json_encode( |
| 219 | ObjectSerializer::sanitizeForSerialization($this), |
| 220 | JSON_PRETTY_PRINT |
| 221 | ); |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * Array of property to type mappings. Used for (de)serialization. |
| 226 | * |
| 227 | */ |
| 228 | public static function openAPITypes(): array |
| 229 | { |
| 230 | return self::$openAPITypes; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Array of property to format mappings. Used for (de)serialization. |
| 235 | */ |
| 236 | public static function openAPIFormats(): array |
| 237 | { |
| 238 | return self::$openAPIFormats; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * Checks if a property is nullable. |
| 243 | * |
| 244 | */ |
| 245 | public static function isNullable(string $property): bool |
| 246 | { |
| 247 | return self::openAPINullables()[$property] ?? false; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Checks if a nullable property is set to null. |
| 252 | * |
| 253 | */ |
| 254 | public function isNullableSetToNull(string $property): bool |
| 255 | { |
| 256 | return in_array($property, $this->getOpenAPINullablesSetToNull(), true); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Array of attributes where the key is the local name, |
| 261 | * and the value is the original name. |
| 262 | * |
| 263 | */ |
| 264 | public static function attributeMap(): array |
| 265 | { |
| 266 | return self::$attributeMap; |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Array of attributes to setter functions (for deserialization of responses). |
| 271 | * |
| 272 | */ |
| 273 | public static function setters(): array |
| 274 | { |
| 275 | return self::$setters; |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Array of attributes to getter functions (for serialization of requests). |
| 280 | * |
| 281 | */ |
| 282 | public static function getters(): array |
| 283 | { |
| 284 | return self::$getters; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * The original name of the model. |
| 289 | * |
| 290 | */ |
| 291 | public function getModelName(): string |
| 292 | { |
| 293 | return self::$openAPIModelName; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Show all the invalid properties with reasons. |
| 298 | * |
| 299 | * @return array invalid properties with reasons |
| 300 | */ |
| 301 | public function listInvalidProperties(): array |
| 302 | { |
| 303 | $invalidProperties = []; |
| 304 | |
| 305 | if (!is_null($this->container['accuracy_radius']) && ($this->container['accuracy_radius'] < 0)) { |
| 306 | $invalidProperties[] = "invalid value for 'accuracy_radius', must be bigger than or equal to 0."; |
| 307 | } |
| 308 | |
| 309 | if (!is_null($this->container['latitude']) && ($this->container['latitude'] > 90)) { |
| 310 | $invalidProperties[] = "invalid value for 'latitude', must be smaller than or equal to 90."; |
| 311 | } |
| 312 | |
| 313 | if (!is_null($this->container['latitude']) && ($this->container['latitude'] < -90)) { |
| 314 | $invalidProperties[] = "invalid value for 'latitude', must be bigger than or equal to -90."; |
| 315 | } |
| 316 | |
| 317 | if (!is_null($this->container['longitude']) && ($this->container['longitude'] > 180)) { |
| 318 | $invalidProperties[] = "invalid value for 'longitude', must be smaller than or equal to 180."; |
| 319 | } |
| 320 | |
| 321 | if (!is_null($this->container['longitude']) && ($this->container['longitude'] < -180)) { |
| 322 | $invalidProperties[] = "invalid value for 'longitude', must be bigger than or equal to -180."; |
| 323 | } |
| 324 | |
| 325 | if (!is_null($this->container['country_code']) && (mb_strlen($this->container['country_code']) > 2)) { |
| 326 | $invalidProperties[] = "invalid value for 'country_code', the character length must be smaller than or equal to 2."; |
| 327 | } |
| 328 | |
| 329 | if (!is_null($this->container['country_code']) && (mb_strlen($this->container['country_code']) < 2)) { |
| 330 | $invalidProperties[] = "invalid value for 'country_code', the character length must be bigger than or equal to 2."; |
| 331 | } |
| 332 | |
| 333 | if (!is_null($this->container['continent_code']) && (mb_strlen($this->container['continent_code']) > 2)) { |
| 334 | $invalidProperties[] = "invalid value for 'continent_code', the character length must be smaller than or equal to 2."; |
| 335 | } |
| 336 | |
| 337 | if (!is_null($this->container['continent_code']) && (mb_strlen($this->container['continent_code']) < 2)) { |
| 338 | $invalidProperties[] = "invalid value for 'continent_code', the character length must be bigger than or equal to 2."; |
| 339 | } |
| 340 | |
| 341 | return $invalidProperties; |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Validate all the properties in the model |
| 346 | * return true if all passed. |
| 347 | * |
| 348 | * @return bool True if all properties are valid |
| 349 | */ |
| 350 | public function valid(): bool |
| 351 | { |
| 352 | return 0 === count($this->listInvalidProperties()); |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * Gets accuracy_radius. |
| 357 | * |
| 358 | */ |
| 359 | public function getAccuracyRadius(): ?int |
| 360 | { |
| 361 | return $this->container['accuracy_radius']; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Sets accuracy_radius. |
| 366 | * |
| 367 | * @param int $accuracy_radius the IP address is likely to be within this radius (in km) of the specified location |
| 368 | * |
| 369 | */ |
| 370 | public function setAccuracyRadius(int $accuracy_radius): self |
| 371 | { |
| 372 | if ($accuracy_radius < 0) { |
| 373 | throw new \InvalidArgumentException('invalid value for $accuracy_radius when calling Geolocation., must be bigger than or equal to 0.'); |
| 374 | } |
| 375 | |
| 376 | $this->container['accuracy_radius'] = $accuracy_radius; |
| 377 | |
| 378 | return $this; |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Gets latitude. |
| 383 | * |
| 384 | */ |
| 385 | public function getLatitude(): ?float |
| 386 | { |
| 387 | return $this->container['latitude']; |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * Sets latitude. |
| 392 | * |
| 393 | * @param float $latitude latitude |
| 394 | * |
| 395 | */ |
| 396 | public function setLatitude(float $latitude): self |
| 397 | { |
| 398 | if ($latitude > 90) { |
| 399 | throw new \InvalidArgumentException('invalid value for $latitude when calling Geolocation., must be smaller than or equal to 90.'); |
| 400 | } |
| 401 | if ($latitude < -90) { |
| 402 | throw new \InvalidArgumentException('invalid value for $latitude when calling Geolocation., must be bigger than or equal to -90.'); |
| 403 | } |
| 404 | |
| 405 | $this->container['latitude'] = $latitude; |
| 406 | |
| 407 | return $this; |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * Gets longitude. |
| 412 | * |
| 413 | */ |
| 414 | public function getLongitude(): ?float |
| 415 | { |
| 416 | return $this->container['longitude']; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * Sets longitude. |
| 421 | * |
| 422 | * @param float $longitude longitude |
| 423 | * |
| 424 | */ |
| 425 | public function setLongitude(float $longitude): self |
| 426 | { |
| 427 | if ($longitude > 180) { |
| 428 | throw new \InvalidArgumentException('invalid value for $longitude when calling Geolocation., must be smaller than or equal to 180.'); |
| 429 | } |
| 430 | if ($longitude < -180) { |
| 431 | throw new \InvalidArgumentException('invalid value for $longitude when calling Geolocation., must be bigger than or equal to -180.'); |
| 432 | } |
| 433 | |
| 434 | $this->container['longitude'] = $longitude; |
| 435 | |
| 436 | return $this; |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Gets postal_code. |
| 441 | * |
| 442 | */ |
| 443 | public function getPostalCode(): ?string |
| 444 | { |
| 445 | return $this->container['postal_code']; |
| 446 | } |
| 447 | |
| 448 | /** |
| 449 | * Sets postal_code. |
| 450 | * |
| 451 | * @param string $postal_code postal_code |
| 452 | * |
| 453 | */ |
| 454 | public function setPostalCode(string $postal_code): self |
| 455 | { |
| 456 | $this->container['postal_code'] = $postal_code; |
| 457 | |
| 458 | return $this; |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Gets timezone. |
| 463 | * |
| 464 | */ |
| 465 | public function getTimezone(): ?string |
| 466 | { |
| 467 | return $this->container['timezone']; |
| 468 | } |
| 469 | |
| 470 | /** |
| 471 | * Sets timezone. |
| 472 | * |
| 473 | * @param string $timezone timezone |
| 474 | * |
| 475 | */ |
| 476 | public function setTimezone(string $timezone): self |
| 477 | { |
| 478 | $this->container['timezone'] = $timezone; |
| 479 | |
| 480 | return $this; |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * Gets city_name. |
| 485 | * |
| 486 | */ |
| 487 | public function getCityName(): ?string |
| 488 | { |
| 489 | return $this->container['city_name']; |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * Sets city_name. |
| 494 | * |
| 495 | * @param string $city_name city_name |
| 496 | * |
| 497 | */ |
| 498 | public function setCityName(string $city_name): self |
| 499 | { |
| 500 | $this->container['city_name'] = $city_name; |
| 501 | |
| 502 | return $this; |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * Gets country_code. |
| 507 | * |
| 508 | */ |
| 509 | public function getCountryCode(): ?string |
| 510 | { |
| 511 | return $this->container['country_code']; |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Sets country_code. |
| 516 | * |
| 517 | * @param string $country_code country_code |
| 518 | * |
| 519 | */ |
| 520 | public function setCountryCode(string $country_code): self |
| 521 | { |
| 522 | if (mb_strlen($country_code) > 2) { |
| 523 | throw new \InvalidArgumentException('invalid length for $country_code when calling Geolocation., must be smaller than or equal to 2.'); |
| 524 | } |
| 525 | if (mb_strlen($country_code) < 2) { |
| 526 | throw new \InvalidArgumentException('invalid length for $country_code when calling Geolocation., must be bigger than or equal to 2.'); |
| 527 | } |
| 528 | |
| 529 | $this->container['country_code'] = $country_code; |
| 530 | |
| 531 | return $this; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Gets country_name. |
| 536 | * |
| 537 | */ |
| 538 | public function getCountryName(): ?string |
| 539 | { |
| 540 | return $this->container['country_name']; |
| 541 | } |
| 542 | |
| 543 | /** |
| 544 | * Sets country_name. |
| 545 | * |
| 546 | * @param string $country_name country_name |
| 547 | * |
| 548 | */ |
| 549 | public function setCountryName(string $country_name): self |
| 550 | { |
| 551 | $this->container['country_name'] = $country_name; |
| 552 | |
| 553 | return $this; |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Gets continent_code. |
| 558 | * |
| 559 | */ |
| 560 | public function getContinentCode(): ?string |
| 561 | { |
| 562 | return $this->container['continent_code']; |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * Sets continent_code. |
| 567 | * |
| 568 | * @param string $continent_code continent_code |
| 569 | * |
| 570 | */ |
| 571 | public function setContinentCode(string $continent_code): self |
| 572 | { |
| 573 | if (mb_strlen($continent_code) > 2) { |
| 574 | throw new \InvalidArgumentException('invalid length for $continent_code when calling Geolocation., must be smaller than or equal to 2.'); |
| 575 | } |
| 576 | if (mb_strlen($continent_code) < 2) { |
| 577 | throw new \InvalidArgumentException('invalid length for $continent_code when calling Geolocation., must be bigger than or equal to 2.'); |
| 578 | } |
| 579 | |
| 580 | $this->container['continent_code'] = $continent_code; |
| 581 | |
| 582 | return $this; |
| 583 | } |
| 584 | |
| 585 | /** |
| 586 | * Gets continent_name. |
| 587 | * |
| 588 | */ |
| 589 | public function getContinentName(): ?string |
| 590 | { |
| 591 | return $this->container['continent_name']; |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * Sets continent_name. |
| 596 | * |
| 597 | * @param string $continent_name continent_name |
| 598 | * |
| 599 | */ |
| 600 | public function setContinentName(string $continent_name): self |
| 601 | { |
| 602 | $this->container['continent_name'] = $continent_name; |
| 603 | |
| 604 | return $this; |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Gets subdivisions. |
| 609 | * |
| 610 | * @return GeolocationSubdivisionsInner[]|null |
| 611 | */ |
| 612 | public function getSubdivisions(): ?array |
| 613 | { |
| 614 | return $this->container['subdivisions']; |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Sets subdivisions. |
| 619 | * |
| 620 | * @param GeolocationSubdivisionsInner[] $subdivisions subdivisions |
| 621 | * |
| 622 | */ |
| 623 | public function setSubdivisions(array $subdivisions): self |
| 624 | { |
| 625 | $this->container['subdivisions'] = $subdivisions; |
| 626 | |
| 627 | return $this; |
| 628 | } |
| 629 | |
| 630 | /** |
| 631 | * Returns true if offset exists. False otherwise. |
| 632 | * |
| 633 | * @param int|string $offset Offset |
| 634 | * |
| 635 | */ |
| 636 | public function offsetExists(mixed $offset): bool |
| 637 | { |
| 638 | return isset($this->container[$offset]); |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Gets offset. |
| 643 | * |
| 644 | * @param int|string $offset Offset |
| 645 | * |
| 646 | * @return mixed|null |
| 647 | */ |
| 648 | #[\ReturnTypeWillChange] |
| 649 | public function offsetGet(mixed $offset): mixed |
| 650 | { |
| 651 | return $this->container[$offset] ?? null; |
| 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Sets value based on offset. |
| 656 | * |
| 657 | * @param int|null $offset Offset |
| 658 | * @param mixed $value Value to be set |
| 659 | * |
| 660 | */ |
| 661 | public function offsetSet(mixed $offset, mixed $value): void |
| 662 | { |
| 663 | if (is_null($offset)) { |
| 664 | $this->container[] = $value; |
| 665 | } else { |
| 666 | $this->container[$offset] = $value; |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | /** |
| 671 | * Unsets offset. |
| 672 | * |
| 673 | * @param int|string $offset Offset |
| 674 | * |
| 675 | */ |
| 676 | public function offsetUnset(mixed $offset): void |
| 677 | { |
| 678 | unset($this->container[$offset]); |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * Serializes the object to a value that can be serialized natively by json_encode(). |
| 683 | * |
| 684 | * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php |
| 685 | * |
| 686 | * @return mixed returns data which can be serialized by json_encode(), which is a value |
| 687 | * of any type other than a resource |
| 688 | */ |
| 689 | #[\ReturnTypeWillChange] |
| 690 | public function jsonSerialize(): mixed |
| 691 | { |
| 692 | return ObjectSerializer::sanitizeForSerialization($this); |
| 693 | } |
| 694 | |
| 695 | /** |
| 696 | * Gets a header-safe presentation of the object. |
| 697 | * |
| 698 | */ |
| 699 | public function toHeaderValue(): string |
| 700 | { |
| 701 | return json_encode(ObjectSerializer::sanitizeForSerialization($this)); |
| 702 | } |
| 703 | |
| 704 | /** |
| 705 | * Array of nullable properties. |
| 706 | */ |
| 707 | protected static function openAPINullables(): array |
| 708 | { |
| 709 | return self::$openAPINullables; |
| 710 | } |
| 711 | |
| 712 | /** |
| 713 | * Array of nullable field names deliberately set to null. |
| 714 | * |
| 715 | * @return bool[] |
| 716 | */ |
| 717 | private function getOpenAPINullablesSetToNull(): array |
| 718 | { |
| 719 | return $this->openAPINullablesSetToNull; |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * Setter - Array of nullable field names deliberately set to null. |
| 724 | * |
| 725 | * @param bool[] $openAPINullablesSetToNull |
| 726 | * |
| 727 | * @codeCoverageIgnore |
| 728 | */ |
| 729 | private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void |
| 730 | { |
| 731 | $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; |
| 732 | } |
| 733 | |
| 734 | /** |
| 735 | * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName |
| 736 | * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the |
| 737 | * $this->openAPINullablesSetToNull array. |
| 738 | * |
| 739 | * @noinspection PhpSameParameterValueInspection |
| 740 | */ |
| 741 | private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void |
| 742 | { |
| 743 | if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { |
| 744 | $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore |
| 745 | } |
| 746 | |
| 747 | $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; |
| 748 | } |
| 749 | } |