Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
39 / 39
100.00% covered (success)
100.00%
25 / 25
CRAP
100.00% covered (success)
100.00%
1 / 1
GeolocationSubdivisionsInner
100.00% covered (success)
100.00%
39 / 39
100.00% covered (success)
100.00%
25 / 25
32
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 openAPITypes
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 openAPIFormats
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isNullable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isNullableSetToNull
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 attributeMap
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setters
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getters
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getModelName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 listInvalidProperties
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getIsoCode
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setIsoCode
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 offsetExists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetGet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetSet
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 offsetUnset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toHeaderValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 openAPINullables
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOpenAPINullablesSetToNull
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setOpenAPINullablesSetToNull
n/a
0 / 0
n/a
0 / 0
1
 setIfExists
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3/**
4 * GeolocationSubdivisionsInner.
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
30namespace Fingerprint\ServerSdk\Model;
31
32use Fingerprint\ServerSdk\ObjectSerializer;
33
34/**
35 * GeolocationSubdivisionsInner 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 */
48class GeolocationSubdivisionsInner 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_subdivisions_inner';
57
58    /**
59     * Array of property to type mappings. Used for (de)serialization.
60     *
61     * @var string[]
62     */
63    protected static array $openAPITypes = [
64        'iso_code' => 'string',
65        'name' => 'string',
66    ];
67
68    /**
69     * Array of property to format mappings. Used for (de)serialization.
70     *
71     * @var string[]
72     *
73     * @phpstan-var array<string, string|null>
74     *
75     * @psalm-var array<string, string|null>
76     */
77    protected static array $openAPIFormats = [
78        'iso_code' => null,
79        'name' => null,
80    ];
81
82    /**
83     * Array of nullable properties. Used for (de)serialization.
84     *
85     * @var bool[]
86     */
87    protected static array $openAPINullables = [
88        'iso_code' => false,
89        'name' => false,
90    ];
91
92    /**
93     * If a nullable field gets set to null, insert it here.
94     *
95     * @var bool[]
96     */
97    protected array $openAPINullablesSetToNull = [];
98
99    /**
100     * Array of attributes where the key is the local name,
101     * and the value is the original name.
102     *
103     * @var string[]
104     */
105    protected static array $attributeMap = [
106        'iso_code' => 'iso_code',
107        'name' => 'name',
108    ];
109
110    /**
111     * Array of attributes to setter functions (for deserialization of responses).
112     *
113     * @var string[]
114     */
115    protected static array $setters = [
116        'iso_code' => 'setIsoCode',
117        'name' => 'setName',
118    ];
119
120    /**
121     * Array of attributes to getter functions (for serialization of requests).
122     *
123     * @var string[]
124     */
125    protected static array $getters = [
126        'iso_code' => 'getIsoCode',
127        'name' => 'getName',
128    ];
129
130    /**
131     * Associative array for storing property values.
132     */
133    protected array $container = [];
134
135    /**
136     * Constructor.
137     *
138     * @param array|null $data Associated array of property values
139     *                         initializing the model
140     *
141     * @noinspection DuplicatedCode
142     */
143    public function __construct(?array $data = null)
144    {
145        $this->setIfExists('iso_code', $data ?? [], null);
146        $this->setIfExists('name', $data ?? [], null);
147    }
148
149    /**
150     * Gets the string presentation of the object.
151     *
152     */
153    public function __toString(): string
154    {
155        return json_encode(
156            ObjectSerializer::sanitizeForSerialization($this),
157            JSON_PRETTY_PRINT
158        );
159    }
160
161    /**
162     * Array of property to type mappings. Used for (de)serialization.
163     *
164     */
165    public static function openAPITypes(): array
166    {
167        return self::$openAPITypes;
168    }
169
170    /**
171     * Array of property to format mappings. Used for (de)serialization.
172     */
173    public static function openAPIFormats(): array
174    {
175        return self::$openAPIFormats;
176    }
177
178    /**
179     * Checks if a property is nullable.
180     *
181     */
182    public static function isNullable(string $property): bool
183    {
184        return self::openAPINullables()[$property] ?? false;
185    }
186
187    /**
188     * Checks if a nullable property is set to null.
189     *
190     */
191    public function isNullableSetToNull(string $property): bool
192    {
193        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
194    }
195
196    /**
197     * Array of attributes where the key is the local name,
198     * and the value is the original name.
199     *
200     */
201    public static function attributeMap(): array
202    {
203        return self::$attributeMap;
204    }
205
206    /**
207     * Array of attributes to setter functions (for deserialization of responses).
208     *
209     */
210    public static function setters(): array
211    {
212        return self::$setters;
213    }
214
215    /**
216     * Array of attributes to getter functions (for serialization of requests).
217     *
218     */
219    public static function getters(): array
220    {
221        return self::$getters;
222    }
223
224    /**
225     * The original name of the model.
226     *
227     */
228    public function getModelName(): string
229    {
230        return self::$openAPIModelName;
231    }
232
233    /**
234     * Show all the invalid properties with reasons.
235     *
236     * @return array invalid properties with reasons
237     */
238    public function listInvalidProperties(): array
239    {
240        $invalidProperties = [];
241
242        if (null === $this->container['iso_code']) {
243            $invalidProperties[] = "'iso_code' can't be null";
244        }
245        if (null === $this->container['name']) {
246            $invalidProperties[] = "'name' can't be null";
247        }
248
249        return $invalidProperties;
250    }
251
252    /**
253     * Validate all the properties in the model
254     * return true if all passed.
255     *
256     * @return bool True if all properties are valid
257     */
258    public function valid(): bool
259    {
260        return 0 === count($this->listInvalidProperties());
261    }
262
263    /**
264     * Gets iso_code.
265     *
266     */
267    public function getIsoCode(): ?string
268    {
269        return $this->container['iso_code'];
270    }
271
272    /**
273     * Sets iso_code.
274     *
275     * @param string $iso_code iso_code
276     *
277     */
278    public function setIsoCode(string $iso_code): self
279    {
280        $this->container['iso_code'] = $iso_code;
281
282        return $this;
283    }
284
285    /**
286     * Gets name.
287     *
288     */
289    public function getName(): ?string
290    {
291        return $this->container['name'];
292    }
293
294    /**
295     * Sets name.
296     *
297     * @param string $name name
298     *
299     */
300    public function setName(string $name): self
301    {
302        $this->container['name'] = $name;
303
304        return $this;
305    }
306
307    /**
308     * Returns true if offset exists. False otherwise.
309     *
310     * @param int|string $offset Offset
311     *
312     */
313    public function offsetExists(mixed $offset): bool
314    {
315        return isset($this->container[$offset]);
316    }
317
318    /**
319     * Gets offset.
320     *
321     * @param int|string $offset Offset
322     *
323     * @return mixed|null
324     */
325    #[\ReturnTypeWillChange]
326    public function offsetGet(mixed $offset): mixed
327    {
328        return $this->container[$offset] ?? null;
329    }
330
331    /**
332     * Sets value based on offset.
333     *
334     * @param int|null $offset Offset
335     * @param mixed    $value  Value to be set
336     *
337     */
338    public function offsetSet(mixed $offset, mixed $value): void
339    {
340        if (is_null($offset)) {
341            $this->container[] = $value;
342        } else {
343            $this->container[$offset] = $value;
344        }
345    }
346
347    /**
348     * Unsets offset.
349     *
350     * @param int|string $offset Offset
351     *
352     */
353    public function offsetUnset(mixed $offset): void
354    {
355        unset($this->container[$offset]);
356    }
357
358    /**
359     * Serializes the object to a value that can be serialized natively by json_encode().
360     *
361     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
362     *
363     * @return mixed returns data which can be serialized by json_encode(), which is a value
364     *               of any type other than a resource
365     */
366    #[\ReturnTypeWillChange]
367    public function jsonSerialize(): mixed
368    {
369        return ObjectSerializer::sanitizeForSerialization($this);
370    }
371
372    /**
373     * Gets a header-safe presentation of the object.
374     *
375     */
376    public function toHeaderValue(): string
377    {
378        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
379    }
380
381    /**
382     * Array of nullable properties.
383     */
384    protected static function openAPINullables(): array
385    {
386        return self::$openAPINullables;
387    }
388
389    /**
390     * Array of nullable field names deliberately set to null.
391     *
392     * @return bool[]
393     */
394    private function getOpenAPINullablesSetToNull(): array
395    {
396        return $this->openAPINullablesSetToNull;
397    }
398
399    /**
400     * Setter - Array of nullable field names deliberately set to null.
401     *
402     * @param bool[] $openAPINullablesSetToNull
403     *
404     * @codeCoverageIgnore
405     */
406    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
407    {
408        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
409    }
410
411    /**
412     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
413     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
414     * $this->openAPINullablesSetToNull array.
415     *
416     * @noinspection PhpSameParameterValueInspection
417     */
418    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
419    {
420        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
421            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
422        }
423
424        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
425    }
426}