Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.44% covered (success)
93.44%
57 / 61
91.89% covered (success)
91.89%
34 / 37
CRAP
0.00% covered (danger)
0.00%
0 / 1
IPInfoV6
93.44% covered (success)
93.44%
57 / 61
91.89% covered (success)
91.89%
34 / 37
43.52
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
8 / 8
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
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 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%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAddress
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAddress
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getGeolocation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setGeolocation
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getAsn
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAsn
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAsnName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAsnName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAsnNetwork
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAsnNetwork
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAsnType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAsnType
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getDatacenterResult
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDatacenterResult
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getDatacenterName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDatacenterName
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
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 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 * IPInfoV6.
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 * IPInfoV6 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 IPInfoV6 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 = 'IPInfoV6';
57
58    /**
59     * Array of property to type mappings. Used for (de)serialization.
60     *
61     * @var string[]
62     */
63    protected static array $openAPITypes = [
64        'address' => 'string',
65        'geolocation' => '\Fingerprint\ServerSdk\Model\Geolocation',
66        'asn' => 'string',
67        'asn_name' => 'string',
68        'asn_network' => 'string',
69        'asn_type' => 'string',
70        'datacenter_result' => 'bool',
71        'datacenter_name' => 'string',
72    ];
73
74    /**
75     * Array of property to format mappings. Used for (de)serialization.
76     *
77     * @var string[]
78     *
79     * @phpstan-var array<string, string|null>
80     *
81     * @psalm-var array<string, string|null>
82     */
83    protected static array $openAPIFormats = [
84        'address' => 'ipv6',
85        'geolocation' => null,
86        'asn' => null,
87        'asn_name' => null,
88        'asn_network' => null,
89        'asn_type' => null,
90        'datacenter_result' => null,
91        'datacenter_name' => null,
92    ];
93
94    /**
95     * Array of nullable properties. Used for (de)serialization.
96     *
97     * @var bool[]
98     */
99    protected static array $openAPINullables = [
100        'address' => false,
101        'geolocation' => false,
102        'asn' => false,
103        'asn_name' => false,
104        'asn_network' => false,
105        'asn_type' => false,
106        'datacenter_result' => false,
107        'datacenter_name' => false,
108    ];
109
110    /**
111     * If a nullable field gets set to null, insert it here.
112     *
113     * @var bool[]
114     */
115    protected array $openAPINullablesSetToNull = [];
116
117    /**
118     * Array of attributes where the key is the local name,
119     * and the value is the original name.
120     *
121     * @var string[]
122     */
123    protected static array $attributeMap = [
124        'address' => 'address',
125        'geolocation' => 'geolocation',
126        'asn' => 'asn',
127        'asn_name' => 'asn_name',
128        'asn_network' => 'asn_network',
129        'asn_type' => 'asn_type',
130        'datacenter_result' => 'datacenter_result',
131        'datacenter_name' => 'datacenter_name',
132    ];
133
134    /**
135     * Array of attributes to setter functions (for deserialization of responses).
136     *
137     * @var string[]
138     */
139    protected static array $setters = [
140        'address' => 'setAddress',
141        'geolocation' => 'setGeolocation',
142        'asn' => 'setAsn',
143        'asn_name' => 'setAsnName',
144        'asn_network' => 'setAsnNetwork',
145        'asn_type' => 'setAsnType',
146        'datacenter_result' => 'setDatacenterResult',
147        'datacenter_name' => 'setDatacenterName',
148    ];
149
150    /**
151     * Array of attributes to getter functions (for serialization of requests).
152     *
153     * @var string[]
154     */
155    protected static array $getters = [
156        'address' => 'getAddress',
157        'geolocation' => 'getGeolocation',
158        'asn' => 'getAsn',
159        'asn_name' => 'getAsnName',
160        'asn_network' => 'getAsnNetwork',
161        'asn_type' => 'getAsnType',
162        'datacenter_result' => 'getDatacenterResult',
163        'datacenter_name' => 'getDatacenterName',
164    ];
165
166    /**
167     * Associative array for storing property values.
168     */
169    protected array $container = [];
170
171    /**
172     * Constructor.
173     *
174     * @param array|null $data Associated array of property values
175     *                         initializing the model
176     *
177     * @noinspection DuplicatedCode
178     */
179    public function __construct(?array $data = null)
180    {
181        $this->setIfExists('address', $data ?? [], null);
182        $this->setIfExists('geolocation', $data ?? [], null);
183        $this->setIfExists('asn', $data ?? [], null);
184        $this->setIfExists('asn_name', $data ?? [], null);
185        $this->setIfExists('asn_network', $data ?? [], null);
186        $this->setIfExists('asn_type', $data ?? [], null);
187        $this->setIfExists('datacenter_result', $data ?? [], null);
188        $this->setIfExists('datacenter_name', $data ?? [], null);
189    }
190
191    /**
192     * Gets the string presentation of the object.
193     *
194     */
195    public function __toString(): string
196    {
197        return json_encode(
198            ObjectSerializer::sanitizeForSerialization($this),
199            JSON_PRETTY_PRINT
200        );
201    }
202
203    /**
204     * Array of property to type mappings. Used for (de)serialization.
205     *
206     */
207    public static function openAPITypes(): array
208    {
209        return self::$openAPITypes;
210    }
211
212    /**
213     * Array of property to format mappings. Used for (de)serialization.
214     */
215    public static function openAPIFormats(): array
216    {
217        return self::$openAPIFormats;
218    }
219
220    /**
221     * Checks if a property is nullable.
222     *
223     */
224    public static function isNullable(string $property): bool
225    {
226        return self::openAPINullables()[$property] ?? false;
227    }
228
229    /**
230     * Checks if a nullable property is set to null.
231     *
232     */
233    public function isNullableSetToNull(string $property): bool
234    {
235        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
236    }
237
238    /**
239     * Array of attributes where the key is the local name,
240     * and the value is the original name.
241     *
242     */
243    public static function attributeMap(): array
244    {
245        return self::$attributeMap;
246    }
247
248    /**
249     * Array of attributes to setter functions (for deserialization of responses).
250     *
251     */
252    public static function setters(): array
253    {
254        return self::$setters;
255    }
256
257    /**
258     * Array of attributes to getter functions (for serialization of requests).
259     *
260     */
261    public static function getters(): array
262    {
263        return self::$getters;
264    }
265
266    /**
267     * The original name of the model.
268     *
269     */
270    public function getModelName(): string
271    {
272        return self::$openAPIModelName;
273    }
274
275    /**
276     * Show all the invalid properties with reasons.
277     *
278     * @return array invalid properties with reasons
279     */
280    public function listInvalidProperties(): array
281    {
282        $invalidProperties = [];
283
284        if (null === $this->container['address']) {
285            $invalidProperties[] = "'address' can't be null";
286        }
287
288        return $invalidProperties;
289    }
290
291    /**
292     * Validate all the properties in the model
293     * return true if all passed.
294     *
295     * @return bool True if all properties are valid
296     */
297    public function valid(): bool
298    {
299        return 0 === count($this->listInvalidProperties());
300    }
301
302    /**
303     * Gets address.
304     *
305     */
306    public function getAddress(): ?string
307    {
308        return $this->container['address'];
309    }
310
311    /**
312     * Sets address.
313     *
314     * @param string $address address
315     *
316     */
317    public function setAddress(string $address): self
318    {
319        $this->container['address'] = $address;
320
321        return $this;
322    }
323
324    /**
325     * Gets geolocation.
326     *
327     */
328    public function getGeolocation(): ?Geolocation
329    {
330        return $this->container['geolocation'];
331    }
332
333    /**
334     * Sets geolocation.
335     *
336     * @param Geolocation $geolocation geolocation
337     *
338     */
339    public function setGeolocation(Geolocation $geolocation): self
340    {
341        $this->container['geolocation'] = $geolocation;
342
343        return $this;
344    }
345
346    /**
347     * Gets asn.
348     *
349     */
350    public function getAsn(): ?string
351    {
352        return $this->container['asn'];
353    }
354
355    /**
356     * Sets asn.
357     *
358     * @param string $asn asn
359     *
360     */
361    public function setAsn(string $asn): self
362    {
363        $this->container['asn'] = $asn;
364
365        return $this;
366    }
367
368    /**
369     * Gets asn_name.
370     *
371     */
372    public function getAsnName(): ?string
373    {
374        return $this->container['asn_name'];
375    }
376
377    /**
378     * Sets asn_name.
379     *
380     * @param string $asn_name asn_name
381     *
382     */
383    public function setAsnName(string $asn_name): self
384    {
385        $this->container['asn_name'] = $asn_name;
386
387        return $this;
388    }
389
390    /**
391     * Gets asn_network.
392     *
393     */
394    public function getAsnNetwork(): ?string
395    {
396        return $this->container['asn_network'];
397    }
398
399    /**
400     * Sets asn_network.
401     *
402     * @param string $asn_network asn_network
403     *
404     */
405    public function setAsnNetwork(string $asn_network): self
406    {
407        $this->container['asn_network'] = $asn_network;
408
409        return $this;
410    }
411
412    /**
413     * Gets asn_type.
414     *
415     */
416    public function getAsnType(): ?string
417    {
418        return $this->container['asn_type'];
419    }
420
421    /**
422     * Sets asn_type.
423     *
424     * @param string $asn_type asn_type
425     *
426     */
427    public function setAsnType(string $asn_type): self
428    {
429        $this->container['asn_type'] = $asn_type;
430
431        return $this;
432    }
433
434    /**
435     * Gets datacenter_result.
436     *
437     */
438    public function getDatacenterResult(): ?bool
439    {
440        return $this->container['datacenter_result'];
441    }
442
443    /**
444     * Sets datacenter_result.
445     *
446     * @param bool $datacenter_result datacenter_result
447     *
448     */
449    public function setDatacenterResult(bool $datacenter_result): self
450    {
451        $this->container['datacenter_result'] = $datacenter_result;
452
453        return $this;
454    }
455
456    /**
457     * Gets datacenter_name.
458     *
459     */
460    public function getDatacenterName(): ?string
461    {
462        return $this->container['datacenter_name'];
463    }
464
465    /**
466     * Sets datacenter_name.
467     *
468     * @param string $datacenter_name datacenter_name
469     *
470     */
471    public function setDatacenterName(string $datacenter_name): self
472    {
473        $this->container['datacenter_name'] = $datacenter_name;
474
475        return $this;
476    }
477
478    /**
479     * Returns true if offset exists. False otherwise.
480     *
481     * @param int|string $offset Offset
482     *
483     */
484    public function offsetExists(mixed $offset): bool
485    {
486        return isset($this->container[$offset]);
487    }
488
489    /**
490     * Gets offset.
491     *
492     * @param int|string $offset Offset
493     *
494     * @return mixed|null
495     */
496    #[\ReturnTypeWillChange]
497    public function offsetGet(mixed $offset): mixed
498    {
499        return $this->container[$offset] ?? null;
500    }
501
502    /**
503     * Sets value based on offset.
504     *
505     * @param int|null $offset Offset
506     * @param mixed    $value  Value to be set
507     *
508     */
509    public function offsetSet(mixed $offset, mixed $value): void
510    {
511        if (is_null($offset)) {
512            $this->container[] = $value;
513        } else {
514            $this->container[$offset] = $value;
515        }
516    }
517
518    /**
519     * Unsets offset.
520     *
521     * @param int|string $offset Offset
522     *
523     */
524    public function offsetUnset(mixed $offset): void
525    {
526        unset($this->container[$offset]);
527    }
528
529    /**
530     * Serializes the object to a value that can be serialized natively by json_encode().
531     *
532     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
533     *
534     * @return mixed returns data which can be serialized by json_encode(), which is a value
535     *               of any type other than a resource
536     */
537    #[\ReturnTypeWillChange]
538    public function jsonSerialize(): mixed
539    {
540        return ObjectSerializer::sanitizeForSerialization($this);
541    }
542
543    /**
544     * Gets a header-safe presentation of the object.
545     *
546     */
547    public function toHeaderValue(): string
548    {
549        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
550    }
551
552    /**
553     * Array of nullable properties.
554     */
555    protected static function openAPINullables(): array
556    {
557        return self::$openAPINullables;
558    }
559
560    /**
561     * Array of nullable field names deliberately set to null.
562     *
563     * @return bool[]
564     */
565    private function getOpenAPINullablesSetToNull(): array
566    {
567        return $this->openAPINullablesSetToNull;
568    }
569
570    /**
571     * Setter - Array of nullable field names deliberately set to null.
572     *
573     * @param bool[] $openAPINullablesSetToNull
574     *
575     * @codeCoverageIgnore
576     */
577    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
578    {
579        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
580    }
581
582    /**
583     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
584     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
585     * $this->openAPINullablesSetToNull array.
586     *
587     * @noinspection PhpSameParameterValueInspection
588     */
589    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
590    {
591        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
592            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
593        }
594
595        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
596    }
597}