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