Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.92% covered (success)
95.92%
47 / 49
96.30% covered (success)
96.30%
26 / 27
CRAP
0.00% covered (danger)
0.00%
0 / 1
IdentificationConfidence
95.92% covered (success)
95.92%
47 / 49
96.30% covered (success)
96.30%
26 / 27
37
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
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
75.00% covered (warning)
75.00%
6 / 8
0.00% covered (danger)
0.00%
0 / 1
4.25
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getScore
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setScore
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
 getVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setVersion
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getComment
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setComment
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 * IdentificationConfidence.
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 * The confidence score represents the probability of a false-positive identification. To learn more, visit [Confidence Score](https://docs.fingerprint.com/docs/identification-accuracy-and-confidence#confidence-score). Please note that the confidence score is not yet supported for [High Recall ID](https://docs.fingerprint.com/docs/supplementary-identifiers-highrecall).
36 *
37 * @category Class
38 *
39 * @description The confidence score represents the probability of a false-positive identification. To learn more, visit [Confidence Score](https://docs.fingerprint.com/docs/identification-accuracy-and-confidence#confidence-score). Please note that the confidence score is not yet supported for [High Recall ID](https://docs.fingerprint.com/docs/supplementary-identifiers-highrecall).
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 IdentificationConfidence 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 = 'IdentificationConfidence';
59
60    /**
61     * Array of property to type mappings. Used for (de)serialization.
62     *
63     * @var string[]
64     */
65    protected static array $openAPITypes = [
66        'score' => 'float',
67        'version' => 'string',
68        'comment' => 'string',
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        'score' => 'double',
82        'version' => null,
83        'comment' => null,
84    ];
85
86    /**
87     * Array of nullable properties. Used for (de)serialization.
88     *
89     * @var bool[]
90     */
91    protected static array $openAPINullables = [
92        'score' => false,
93        'version' => false,
94        'comment' => false,
95    ];
96
97    /**
98     * If a nullable field gets set to null, insert it here.
99     *
100     * @var bool[]
101     */
102    protected array $openAPINullablesSetToNull = [];
103
104    /**
105     * Array of attributes where the key is the local name,
106     * and the value is the original name.
107     *
108     * @var string[]
109     */
110    protected static array $attributeMap = [
111        'score' => 'score',
112        'version' => 'version',
113        'comment' => 'comment',
114    ];
115
116    /**
117     * Array of attributes to setter functions (for deserialization of responses).
118     *
119     * @var string[]
120     */
121    protected static array $setters = [
122        'score' => 'setScore',
123        'version' => 'setVersion',
124        'comment' => 'setComment',
125    ];
126
127    /**
128     * Array of attributes to getter functions (for serialization of requests).
129     *
130     * @var string[]
131     */
132    protected static array $getters = [
133        'score' => 'getScore',
134        'version' => 'getVersion',
135        'comment' => 'getComment',
136    ];
137
138    /**
139     * Associative array for storing property values.
140     */
141    protected array $container = [];
142
143    /**
144     * Constructor.
145     *
146     * @param array|null $data Associated array of property values
147     *                         initializing the model
148     *
149     * @noinspection DuplicatedCode
150     */
151    public function __construct(?array $data = null)
152    {
153        $this->setIfExists('score', $data ?? [], null);
154        $this->setIfExists('version', $data ?? [], null);
155        $this->setIfExists('comment', $data ?? [], null);
156    }
157
158    /**
159     * Gets the string presentation of the object.
160     *
161     */
162    public function __toString(): string
163    {
164        return json_encode(
165            ObjectSerializer::sanitizeForSerialization($this),
166            JSON_PRETTY_PRINT
167        );
168    }
169
170    /**
171     * Array of property to type mappings. Used for (de)serialization.
172     *
173     */
174    public static function openAPITypes(): array
175    {
176        return self::$openAPITypes;
177    }
178
179    /**
180     * Array of property to format mappings. Used for (de)serialization.
181     */
182    public static function openAPIFormats(): array
183    {
184        return self::$openAPIFormats;
185    }
186
187    /**
188     * Checks if a property is nullable.
189     *
190     */
191    public static function isNullable(string $property): bool
192    {
193        return self::openAPINullables()[$property] ?? false;
194    }
195
196    /**
197     * Checks if a nullable property is set to null.
198     *
199     */
200    public function isNullableSetToNull(string $property): bool
201    {
202        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
203    }
204
205    /**
206     * Array of attributes where the key is the local name,
207     * and the value is the original name.
208     *
209     */
210    public static function attributeMap(): array
211    {
212        return self::$attributeMap;
213    }
214
215    /**
216     * Array of attributes to setter functions (for deserialization of responses).
217     *
218     */
219    public static function setters(): array
220    {
221        return self::$setters;
222    }
223
224    /**
225     * Array of attributes to getter functions (for serialization of requests).
226     *
227     */
228    public static function getters(): array
229    {
230        return self::$getters;
231    }
232
233    /**
234     * The original name of the model.
235     *
236     */
237    public function getModelName(): string
238    {
239        return self::$openAPIModelName;
240    }
241
242    /**
243     * Show all the invalid properties with reasons.
244     *
245     * @return array invalid properties with reasons
246     */
247    public function listInvalidProperties(): array
248    {
249        $invalidProperties = [];
250
251        if (null === $this->container['score']) {
252            $invalidProperties[] = "'score' can't be null";
253        }
254        if ($this->container['score'] > 1) {
255            $invalidProperties[] = "invalid value for 'score', must be smaller than or equal to 1.";
256        }
257
258        if ($this->container['score'] < 0) {
259            $invalidProperties[] = "invalid value for 'score', must be bigger than or equal to 0.";
260        }
261
262        return $invalidProperties;
263    }
264
265    /**
266     * Validate all the properties in the model
267     * return true if all passed.
268     *
269     * @return bool True if all properties are valid
270     */
271    public function valid(): bool
272    {
273        return 0 === count($this->listInvalidProperties());
274    }
275
276    /**
277     * Gets score.
278     *
279     */
280    public function getScore(): ?float
281    {
282        return $this->container['score'];
283    }
284
285    /**
286     * Sets score.
287     *
288     * @param float $score A floating-point number between 0 and 1 that represents the probability of a false-positive identification. For High Recall ID, this value is 0.
289     *
290     */
291    public function setScore(float $score): self
292    {
293        if ($score > 1) {
294            throw new \InvalidArgumentException('invalid value for $score when calling IdentificationConfidence., must be smaller than or equal to 1.');
295        }
296        if ($score < 0) {
297            throw new \InvalidArgumentException('invalid value for $score when calling IdentificationConfidence., must be bigger than or equal to 0.');
298        }
299
300        $this->container['score'] = $score;
301
302        return $this;
303    }
304
305    /**
306     * Gets version.
307     *
308     */
309    public function getVersion(): ?string
310    {
311        return $this->container['version'];
312    }
313
314    /**
315     * Sets version.
316     *
317     * @param string $version The version name of the method used to calculate the confidence score. For High Recall ID, this value is \"Not Supported\".
318     *
319     */
320    public function setVersion(string $version): self
321    {
322        $this->container['version'] = $version;
323
324        return $this;
325    }
326
327    /**
328     * Gets comment.
329     *
330     */
331    public function getComment(): ?string
332    {
333        return $this->container['comment'];
334    }
335
336    /**
337     * Sets comment.
338     *
339     * @param string $comment comment
340     *
341     */
342    public function setComment(string $comment): self
343    {
344        $this->container['comment'] = $comment;
345
346        return $this;
347    }
348
349    /**
350     * Returns true if offset exists. False otherwise.
351     *
352     * @param int|string $offset Offset
353     *
354     */
355    public function offsetExists(mixed $offset): bool
356    {
357        return isset($this->container[$offset]);
358    }
359
360    /**
361     * Gets offset.
362     *
363     * @param int|string $offset Offset
364     *
365     * @return mixed|null
366     */
367    #[\ReturnTypeWillChange]
368    public function offsetGet(mixed $offset): mixed
369    {
370        return $this->container[$offset] ?? null;
371    }
372
373    /**
374     * Sets value based on offset.
375     *
376     * @param int|null $offset Offset
377     * @param mixed    $value  Value to be set
378     *
379     */
380    public function offsetSet(mixed $offset, mixed $value): void
381    {
382        if (is_null($offset)) {
383            $this->container[] = $value;
384        } else {
385            $this->container[$offset] = $value;
386        }
387    }
388
389    /**
390     * Unsets offset.
391     *
392     * @param int|string $offset Offset
393     *
394     */
395    public function offsetUnset(mixed $offset): void
396    {
397        unset($this->container[$offset]);
398    }
399
400    /**
401     * Serializes the object to a value that can be serialized natively by json_encode().
402     *
403     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
404     *
405     * @return mixed returns data which can be serialized by json_encode(), which is a value
406     *               of any type other than a resource
407     */
408    #[\ReturnTypeWillChange]
409    public function jsonSerialize(): mixed
410    {
411        return ObjectSerializer::sanitizeForSerialization($this);
412    }
413
414    /**
415     * Gets a header-safe presentation of the object.
416     *
417     */
418    public function toHeaderValue(): string
419    {
420        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
421    }
422
423    /**
424     * Array of nullable properties.
425     */
426    protected static function openAPINullables(): array
427    {
428        return self::$openAPINullables;
429    }
430
431    /**
432     * Array of nullable field names deliberately set to null.
433     *
434     * @return bool[]
435     */
436    private function getOpenAPINullablesSetToNull(): array
437    {
438        return $this->openAPINullablesSetToNull;
439    }
440
441    /**
442     * Setter - Array of nullable field names deliberately set to null.
443     *
444     * @param bool[] $openAPINullablesSetToNull
445     *
446     * @codeCoverageIgnore
447     */
448    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
449    {
450        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
451    }
452
453    /**
454     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
455     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
456     * $this->openAPINullablesSetToNull array.
457     *
458     * @noinspection PhpSameParameterValueInspection
459     */
460    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
461    {
462        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
463            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
464        }
465
466        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
467    }
468}