Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
96.08% covered (success)
96.08%
49 / 51
96.77% covered (success)
96.77%
30 / 31
CRAP
0.00% covered (danger)
0.00%
0 / 1
Identification
96.08% covered (success)
96.08%
49 / 51
96.77% covered (success)
96.77%
30 / 31
38
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
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
 getVisitorId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setVisitorId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getConfidence
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setConfidence
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getVisitorFound
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setVisitorFound
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getFirstSeenAt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setFirstSeenAt
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getLastSeenAt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLastSeenAt
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 * Identification.
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 * Identification 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 Identification 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 = 'Identification';
57
58    /**
59     * Array of property to type mappings. Used for (de)serialization.
60     *
61     * @var string[]
62     */
63    protected static array $openAPITypes = [
64        'visitor_id' => 'string',
65        'confidence' => '\Fingerprint\ServerSdk\Model\IdentificationConfidence',
66        'visitor_found' => 'bool',
67        'first_seen_at' => 'int',
68        'last_seen_at' => 'int',
69    ];
70
71    /**
72     * Array of property to format mappings. Used for (de)serialization.
73     *
74     * @var string[]
75     *
76     * @phpstan-var array<string, string|null>
77     *
78     * @psalm-var array<string, string|null>
79     */
80    protected static array $openAPIFormats = [
81        'visitor_id' => null,
82        'confidence' => null,
83        'visitor_found' => null,
84        'first_seen_at' => 'int64',
85        'last_seen_at' => 'int64',
86    ];
87
88    /**
89     * Array of nullable properties. Used for (de)serialization.
90     *
91     * @var bool[]
92     */
93    protected static array $openAPINullables = [
94        'visitor_id' => false,
95        'confidence' => false,
96        'visitor_found' => false,
97        'first_seen_at' => false,
98        'last_seen_at' => false,
99    ];
100
101    /**
102     * If a nullable field gets set to null, insert it here.
103     *
104     * @var bool[]
105     */
106    protected array $openAPINullablesSetToNull = [];
107
108    /**
109     * Array of attributes where the key is the local name,
110     * and the value is the original name.
111     *
112     * @var string[]
113     */
114    protected static array $attributeMap = [
115        'visitor_id' => 'visitor_id',
116        'confidence' => 'confidence',
117        'visitor_found' => 'visitor_found',
118        'first_seen_at' => 'first_seen_at',
119        'last_seen_at' => 'last_seen_at',
120    ];
121
122    /**
123     * Array of attributes to setter functions (for deserialization of responses).
124     *
125     * @var string[]
126     */
127    protected static array $setters = [
128        'visitor_id' => 'setVisitorId',
129        'confidence' => 'setConfidence',
130        'visitor_found' => 'setVisitorFound',
131        'first_seen_at' => 'setFirstSeenAt',
132        'last_seen_at' => 'setLastSeenAt',
133    ];
134
135    /**
136     * Array of attributes to getter functions (for serialization of requests).
137     *
138     * @var string[]
139     */
140    protected static array $getters = [
141        'visitor_id' => 'getVisitorId',
142        'confidence' => 'getConfidence',
143        'visitor_found' => 'getVisitorFound',
144        'first_seen_at' => 'getFirstSeenAt',
145        'last_seen_at' => 'getLastSeenAt',
146    ];
147
148    /**
149     * Associative array for storing property values.
150     */
151    protected array $container = [];
152
153    /**
154     * Constructor.
155     *
156     * @param array|null $data Associated array of property values
157     *                         initializing the model
158     *
159     * @noinspection DuplicatedCode
160     */
161    public function __construct(?array $data = null)
162    {
163        $this->setIfExists('visitor_id', $data ?? [], null);
164        $this->setIfExists('confidence', $data ?? [], null);
165        $this->setIfExists('visitor_found', $data ?? [], null);
166        $this->setIfExists('first_seen_at', $data ?? [], null);
167        $this->setIfExists('last_seen_at', $data ?? [], null);
168    }
169
170    /**
171     * Gets the string presentation of the object.
172     *
173     */
174    public function __toString(): string
175    {
176        return json_encode(
177            ObjectSerializer::sanitizeForSerialization($this),
178            JSON_PRETTY_PRINT
179        );
180    }
181
182    /**
183     * Array of property to type mappings. Used for (de)serialization.
184     *
185     */
186    public static function openAPITypes(): array
187    {
188        return self::$openAPITypes;
189    }
190
191    /**
192     * Array of property to format mappings. Used for (de)serialization.
193     */
194    public static function openAPIFormats(): array
195    {
196        return self::$openAPIFormats;
197    }
198
199    /**
200     * Checks if a property is nullable.
201     *
202     */
203    public static function isNullable(string $property): bool
204    {
205        return self::openAPINullables()[$property] ?? false;
206    }
207
208    /**
209     * Checks if a nullable property is set to null.
210     *
211     */
212    public function isNullableSetToNull(string $property): bool
213    {
214        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
215    }
216
217    /**
218     * Array of attributes where the key is the local name,
219     * and the value is the original name.
220     *
221     */
222    public static function attributeMap(): array
223    {
224        return self::$attributeMap;
225    }
226
227    /**
228     * Array of attributes to setter functions (for deserialization of responses).
229     *
230     */
231    public static function setters(): array
232    {
233        return self::$setters;
234    }
235
236    /**
237     * Array of attributes to getter functions (for serialization of requests).
238     *
239     */
240    public static function getters(): array
241    {
242        return self::$getters;
243    }
244
245    /**
246     * The original name of the model.
247     *
248     */
249    public function getModelName(): string
250    {
251        return self::$openAPIModelName;
252    }
253
254    /**
255     * Show all the invalid properties with reasons.
256     *
257     * @return array invalid properties with reasons
258     */
259    public function listInvalidProperties(): array
260    {
261        $invalidProperties = [];
262
263        if (null === $this->container['visitor_id']) {
264            $invalidProperties[] = "'visitor_id' can't be null";
265        }
266        if (null === $this->container['visitor_found']) {
267            $invalidProperties[] = "'visitor_found' can't be null";
268        }
269
270        return $invalidProperties;
271    }
272
273    /**
274     * Validate all the properties in the model
275     * return true if all passed.
276     *
277     * @return bool True if all properties are valid
278     */
279    public function valid(): bool
280    {
281        return 0 === count($this->listInvalidProperties());
282    }
283
284    /**
285     * Gets visitor_id.
286     *
287     */
288    public function getVisitorId(): ?string
289    {
290        return $this->container['visitor_id'];
291    }
292
293    /**
294     * Sets visitor_id.
295     *
296     * @param string $visitor_id string of 20 characters that uniquely identifies the visitor's browser or mobile device
297     *
298     */
299    public function setVisitorId(string $visitor_id): self
300    {
301        $this->container['visitor_id'] = $visitor_id;
302
303        return $this;
304    }
305
306    /**
307     * Gets confidence.
308     *
309     */
310    public function getConfidence(): ?IdentificationConfidence
311    {
312        return $this->container['confidence'];
313    }
314
315    /**
316     * Sets confidence.
317     *
318     * @param IdentificationConfidence $confidence confidence
319     *
320     */
321    public function setConfidence(IdentificationConfidence $confidence): self
322    {
323        $this->container['confidence'] = $confidence;
324
325        return $this;
326    }
327
328    /**
329     * Gets visitor_found.
330     *
331     */
332    public function getVisitorFound(): ?bool
333    {
334        return $this->container['visitor_found'];
335    }
336
337    /**
338     * Sets visitor_found.
339     *
340     * @param bool $visitor_found attribute represents if a visitor had been identified before
341     *
342     */
343    public function setVisitorFound(bool $visitor_found): self
344    {
345        $this->container['visitor_found'] = $visitor_found;
346
347        return $this;
348    }
349
350    /**
351     * Gets first_seen_at.
352     *
353     */
354    public function getFirstSeenAt(): ?int
355    {
356        return $this->container['first_seen_at'];
357    }
358
359    /**
360     * Sets first_seen_at.
361     *
362     * @param int $first_seen_at Unix epoch time milliseconds timestamp indicating the time at which this visitor ID was first seen. example: `1758069706642` - Corresponding to Wed Sep 17 2025 00:41:46 GMT+0000
363     *
364     */
365    public function setFirstSeenAt(int $first_seen_at): self
366    {
367        $this->container['first_seen_at'] = $first_seen_at;
368
369        return $this;
370    }
371
372    /**
373     * Gets last_seen_at.
374     *
375     */
376    public function getLastSeenAt(): ?int
377    {
378        return $this->container['last_seen_at'];
379    }
380
381    /**
382     * Sets last_seen_at.
383     *
384     * @param int $last_seen_at Unix epoch time milliseconds timestamp indicating the time at which this visitor ID was last seen. example: `1758069706642` - Corresponding to Wed Sep 17 2025 00:41:46 GMT+0000
385     *
386     */
387    public function setLastSeenAt(int $last_seen_at): self
388    {
389        $this->container['last_seen_at'] = $last_seen_at;
390
391        return $this;
392    }
393
394    /**
395     * Returns true if offset exists. False otherwise.
396     *
397     * @param int|string $offset Offset
398     *
399     */
400    public function offsetExists(mixed $offset): bool
401    {
402        return isset($this->container[$offset]);
403    }
404
405    /**
406     * Gets offset.
407     *
408     * @param int|string $offset Offset
409     *
410     * @return mixed|null
411     */
412    #[\ReturnTypeWillChange]
413    public function offsetGet(mixed $offset): mixed
414    {
415        return $this->container[$offset] ?? null;
416    }
417
418    /**
419     * Sets value based on offset.
420     *
421     * @param int|null $offset Offset
422     * @param mixed    $value  Value to be set
423     *
424     */
425    public function offsetSet(mixed $offset, mixed $value): void
426    {
427        if (is_null($offset)) {
428            $this->container[] = $value;
429        } else {
430            $this->container[$offset] = $value;
431        }
432    }
433
434    /**
435     * Unsets offset.
436     *
437     * @param int|string $offset Offset
438     *
439     */
440    public function offsetUnset(mixed $offset): void
441    {
442        unset($this->container[$offset]);
443    }
444
445    /**
446     * Serializes the object to a value that can be serialized natively by json_encode().
447     *
448     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
449     *
450     * @return mixed returns data which can be serialized by json_encode(), which is a value
451     *               of any type other than a resource
452     */
453    #[\ReturnTypeWillChange]
454    public function jsonSerialize(): mixed
455    {
456        return ObjectSerializer::sanitizeForSerialization($this);
457    }
458
459    /**
460     * Gets a header-safe presentation of the object.
461     *
462     */
463    public function toHeaderValue(): string
464    {
465        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
466    }
467
468    /**
469     * Array of nullable properties.
470     */
471    protected static function openAPINullables(): array
472    {
473        return self::$openAPINullables;
474    }
475
476    /**
477     * Array of nullable field names deliberately set to null.
478     *
479     * @return bool[]
480     */
481    private function getOpenAPINullablesSetToNull(): array
482    {
483        return $this->openAPINullablesSetToNull;
484    }
485
486    /**
487     * Setter - Array of nullable field names deliberately set to null.
488     *
489     * @param bool[] $openAPINullablesSetToNull
490     *
491     * @codeCoverageIgnore
492     */
493    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
494    {
495        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
496    }
497
498    /**
499     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
500     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
501     * $this->openAPINullablesSetToNull array.
502     *
503     * @noinspection PhpSameParameterValueInspection
504     */
505    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
506    {
507        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
508            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
509        }
510
511        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
512    }
513}