Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
97.50% covered (success)
97.50%
78 / 80
96.43% covered (success)
96.43%
27 / 28
CRAP
0.00% covered (danger)
0.00%
0 / 1
Proximity
97.50% covered (success)
97.50%
78 / 80
96.43% covered (success)
96.43%
27 / 28
43
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
 getPrecisionRadiusAllowableValues
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
 listInvalidProperties
89.47% covered (warning)
89.47%
17 / 19
0.00% covered (danger)
0.00%
0 / 1
8.07
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getPrecisionRadius
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPrecisionRadius
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
 getConfidence
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setConfidence
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
 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 * Proximity.
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 * Proximity ID represents a fixed geographical zone in a discrete global grid within which the device is observed.
36 *
37 * @category Class
38 *
39 * @description Proximity ID represents a fixed geographical zone in a discrete global grid within which the device is observed.
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 Proximity implements ModelInterface, \ArrayAccess, \JsonSerializable
51{
52    public const DISCRIMINATOR = null;
53
54    public const PRECISION_RADIUS_NUMBER_10 = 10;
55    public const PRECISION_RADIUS_NUMBER_25 = 25;
56    public const PRECISION_RADIUS_NUMBER_65 = 65;
57    public const PRECISION_RADIUS_NUMBER_175 = 175;
58    public const PRECISION_RADIUS_NUMBER_450 = 450;
59    public const PRECISION_RADIUS_NUMBER_1200 = 1200;
60    public const PRECISION_RADIUS_NUMBER_3300 = 3300;
61    public const PRECISION_RADIUS_NUMBER_8500 = 8500;
62    public const PRECISION_RADIUS_NUMBER_22500 = 22500;
63
64    /**
65     * The original name of the model.
66     *
67     */
68    protected static string $openAPIModelName = 'Proximity';
69
70    /**
71     * Array of property to type mappings. Used for (de)serialization.
72     *
73     * @var string[]
74     */
75    protected static array $openAPITypes = [
76        'id' => 'string',
77        'precision_radius' => 'int',
78        'confidence' => 'float',
79    ];
80
81    /**
82     * Array of property to format mappings. Used for (de)serialization.
83     *
84     * @var string[]
85     *
86     * @phpstan-var array<string, string|null>
87     *
88     * @psalm-var array<string, string|null>
89     */
90    protected static array $openAPIFormats = [
91        'id' => null,
92        'precision_radius' => 'int32',
93        'confidence' => 'float',
94    ];
95
96    /**
97     * Array of nullable properties. Used for (de)serialization.
98     *
99     * @var bool[]
100     */
101    protected static array $openAPINullables = [
102        'id' => false,
103        'precision_radius' => false,
104        'confidence' => false,
105    ];
106
107    /**
108     * If a nullable field gets set to null, insert it here.
109     *
110     * @var bool[]
111     */
112    protected array $openAPINullablesSetToNull = [];
113
114    /**
115     * Array of attributes where the key is the local name,
116     * and the value is the original name.
117     *
118     * @var string[]
119     */
120    protected static array $attributeMap = [
121        'id' => 'id',
122        'precision_radius' => 'precision_radius',
123        'confidence' => 'confidence',
124    ];
125
126    /**
127     * Array of attributes to setter functions (for deserialization of responses).
128     *
129     * @var string[]
130     */
131    protected static array $setters = [
132        'id' => 'setId',
133        'precision_radius' => 'setPrecisionRadius',
134        'confidence' => 'setConfidence',
135    ];
136
137    /**
138     * Array of attributes to getter functions (for serialization of requests).
139     *
140     * @var string[]
141     */
142    protected static array $getters = [
143        'id' => 'getId',
144        'precision_radius' => 'getPrecisionRadius',
145        'confidence' => 'getConfidence',
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('id', $data ?? [], null);
164        $this->setIfExists('precision_radius', $data ?? [], null);
165        $this->setIfExists('confidence', $data ?? [], null);
166    }
167
168    /**
169     * Gets the string presentation of the object.
170     *
171     */
172    public function __toString(): string
173    {
174        return json_encode(
175            ObjectSerializer::sanitizeForSerialization($this),
176            JSON_PRETTY_PRINT
177        );
178    }
179
180    /**
181     * Array of property to type mappings. Used for (de)serialization.
182     *
183     */
184    public static function openAPITypes(): array
185    {
186        return self::$openAPITypes;
187    }
188
189    /**
190     * Array of property to format mappings. Used for (de)serialization.
191     */
192    public static function openAPIFormats(): array
193    {
194        return self::$openAPIFormats;
195    }
196
197    /**
198     * Checks if a property is nullable.
199     *
200     */
201    public static function isNullable(string $property): bool
202    {
203        return self::openAPINullables()[$property] ?? false;
204    }
205
206    /**
207     * Checks if a nullable property is set to null.
208     *
209     */
210    public function isNullableSetToNull(string $property): bool
211    {
212        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
213    }
214
215    /**
216     * Array of attributes where the key is the local name,
217     * and the value is the original name.
218     *
219     */
220    public static function attributeMap(): array
221    {
222        return self::$attributeMap;
223    }
224
225    /**
226     * Array of attributes to setter functions (for deserialization of responses).
227     *
228     */
229    public static function setters(): array
230    {
231        return self::$setters;
232    }
233
234    /**
235     * Array of attributes to getter functions (for serialization of requests).
236     *
237     */
238    public static function getters(): array
239    {
240        return self::$getters;
241    }
242
243    /**
244     * The original name of the model.
245     *
246     */
247    public function getModelName(): string
248    {
249        return self::$openAPIModelName;
250    }
251
252    /**
253     * Gets allowable values of the enum.
254     *
255     * @return string[]
256     */
257    public function getPrecisionRadiusAllowableValues(): array
258    {
259        return [
260            self::PRECISION_RADIUS_NUMBER_10,
261            self::PRECISION_RADIUS_NUMBER_25,
262            self::PRECISION_RADIUS_NUMBER_65,
263            self::PRECISION_RADIUS_NUMBER_175,
264            self::PRECISION_RADIUS_NUMBER_450,
265            self::PRECISION_RADIUS_NUMBER_1200,
266            self::PRECISION_RADIUS_NUMBER_3300,
267            self::PRECISION_RADIUS_NUMBER_8500,
268            self::PRECISION_RADIUS_NUMBER_22500,
269        ];
270    }
271
272    /**
273     * Show all the invalid properties with reasons.
274     *
275     * @return array invalid properties with reasons
276     */
277    public function listInvalidProperties(): array
278    {
279        $invalidProperties = [];
280
281        if (null === $this->container['id']) {
282            $invalidProperties[] = "'id' can't be null";
283        }
284        if (null === $this->container['precision_radius']) {
285            $invalidProperties[] = "'precision_radius' can't be null";
286        }
287        $allowedValues = $this->getPrecisionRadiusAllowableValues();
288        if (!is_null($this->container['precision_radius']) && !in_array($this->container['precision_radius'], $allowedValues, true)) {
289            $invalidProperties[] = sprintf(
290                "invalid value '%s' for 'precision_radius', must be one of '%s'",
291                $this->container['precision_radius'],
292                implode("', '", $allowedValues)
293            );
294        }
295
296        if (null === $this->container['confidence']) {
297            $invalidProperties[] = "'confidence' can't be null";
298        }
299        if ($this->container['confidence'] > 1) {
300            $invalidProperties[] = "invalid value for 'confidence', must be smaller than or equal to 1.";
301        }
302
303        if ($this->container['confidence'] < 0) {
304            $invalidProperties[] = "invalid value for 'confidence', must be bigger than or equal to 0.";
305        }
306
307        return $invalidProperties;
308    }
309
310    /**
311     * Validate all the properties in the model
312     * return true if all passed.
313     *
314     * @return bool True if all properties are valid
315     */
316    public function valid(): bool
317    {
318        return 0 === count($this->listInvalidProperties());
319    }
320
321    /**
322     * Gets id.
323     *
324     */
325    public function getId(): ?string
326    {
327        return $this->container['id'];
328    }
329
330    /**
331     * Sets id.
332     *
333     * @param string $id a stable privacy-preserving identifier for a given proximity zone
334     *
335     */
336    public function setId(string $id): self
337    {
338        $this->container['id'] = $id;
339
340        return $this;
341    }
342
343    /**
344     * Gets precision_radius.
345     *
346     */
347    public function getPrecisionRadius(): ?int
348    {
349        return $this->container['precision_radius'];
350    }
351
352    /**
353     * Sets precision_radius.
354     *
355     * @param int $precision_radius the radius of the proximity zone’s precision level, in meters
356     *
357     */
358    public function setPrecisionRadius(int $precision_radius): self
359    {
360        $allowedValues = $this->getPrecisionRadiusAllowableValues();
361        if (!in_array($precision_radius, $allowedValues, true)) {
362            throw new \InvalidArgumentException(
363                sprintf(
364                    "Invalid value '%s' for 'precision_radius', must be one of '%s'",
365                    $precision_radius,
366                    implode("', '", $allowedValues)
367                )
368            );
369        }
370        $this->container['precision_radius'] = $precision_radius;
371
372        return $this;
373    }
374
375    /**
376     * Gets confidence.
377     *
378     */
379    public function getConfidence(): ?float
380    {
381        return $this->container['confidence'];
382    }
383
384    /**
385     * Sets confidence.
386     *
387     * @param float $confidence A value between `0` and `1` representing the likelihood that the true device location lies within the mapped proximity zone.   * Scores closer to `1` indicate high confidence that the location is inside the mapped proximity zone.   * Scores closer to `0` indicate lower confidence, suggesting the true location may fall in an adjacent zone.
388     *
389     */
390    public function setConfidence(float $confidence): self
391    {
392        if ($confidence > 1) {
393            throw new \InvalidArgumentException('invalid value for $confidence when calling Proximity., must be smaller than or equal to 1.');
394        }
395        if ($confidence < 0) {
396            throw new \InvalidArgumentException('invalid value for $confidence when calling Proximity., must be bigger than or equal to 0.');
397        }
398
399        $this->container['confidence'] = $confidence;
400
401        return $this;
402    }
403
404    /**
405     * Returns true if offset exists. False otherwise.
406     *
407     * @param int|string $offset Offset
408     *
409     */
410    public function offsetExists(mixed $offset): bool
411    {
412        return isset($this->container[$offset]);
413    }
414
415    /**
416     * Gets offset.
417     *
418     * @param int|string $offset Offset
419     *
420     * @return mixed|null
421     */
422    #[\ReturnTypeWillChange]
423    public function offsetGet(mixed $offset): mixed
424    {
425        return $this->container[$offset] ?? null;
426    }
427
428    /**
429     * Sets value based on offset.
430     *
431     * @param int|null $offset Offset
432     * @param mixed    $value  Value to be set
433     *
434     */
435    public function offsetSet(mixed $offset, mixed $value): void
436    {
437        if (is_null($offset)) {
438            $this->container[] = $value;
439        } else {
440            $this->container[$offset] = $value;
441        }
442    }
443
444    /**
445     * Unsets offset.
446     *
447     * @param int|string $offset Offset
448     *
449     */
450    public function offsetUnset(mixed $offset): void
451    {
452        unset($this->container[$offset]);
453    }
454
455    /**
456     * Serializes the object to a value that can be serialized natively by json_encode().
457     *
458     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
459     *
460     * @return mixed returns data which can be serialized by json_encode(), which is a value
461     *               of any type other than a resource
462     */
463    #[\ReturnTypeWillChange]
464    public function jsonSerialize(): mixed
465    {
466        return ObjectSerializer::sanitizeForSerialization($this);
467    }
468
469    /**
470     * Gets a header-safe presentation of the object.
471     *
472     */
473    public function toHeaderValue(): string
474    {
475        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
476    }
477
478    /**
479     * Array of nullable properties.
480     */
481    protected static function openAPINullables(): array
482    {
483        return self::$openAPINullables;
484    }
485
486    /**
487     * Array of nullable field names deliberately set to null.
488     *
489     * @return bool[]
490     */
491    private function getOpenAPINullablesSetToNull(): array
492    {
493        return $this->openAPINullablesSetToNull;
494    }
495
496    /**
497     * Setter - Array of nullable field names deliberately set to null.
498     *
499     * @param bool[] $openAPINullablesSetToNull
500     *
501     * @codeCoverageIgnore
502     */
503    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
504    {
505        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
506    }
507
508    /**
509     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
510     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
511     * $this->openAPINullablesSetToNull array.
512     *
513     * @noinspection PhpSameParameterValueInspection
514     */
515    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
516    {
517        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
518            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
519        }
520
521        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
522    }
523}