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