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