Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
96.88% covered (success)
96.88%
62 / 64
96.43% covered (success)
96.43%
27 / 28
CRAP
0.00% covered (danger)
0.00%
0 / 1
Proximity
96.88% covered (success)
96.88%
62 / 64
96.43% covered (success)
96.43%
27 / 28
40
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
83.33% covered (warning)
83.33%
10 / 12
0.00% covered (danger)
0.00%
0 / 1
6.17
 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%
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
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. The API also supports collection of Automation Intelligence for requests to your server in edge, pre-origin, or middleware contexts.
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.23.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        if (null === $this->container['confidence']) {
288            $invalidProperties[] = "'confidence' can't be null";
289        }
290        if ($this->container['confidence'] > 1) {
291            $invalidProperties[] = "invalid value for 'confidence', must be smaller than or equal to 1.";
292        }
293
294        if ($this->container['confidence'] < 0) {
295            $invalidProperties[] = "invalid value for 'confidence', must be bigger than or equal to 0.";
296        }
297
298        return $invalidProperties;
299    }
300
301    /**
302     * Validate all the properties in the model
303     * return true if all passed.
304     *
305     * @return bool True if all properties are valid
306     */
307    public function valid(): bool
308    {
309        return 0 === count($this->listInvalidProperties());
310    }
311
312    /**
313     * Gets id.
314     *
315     */
316    public function getId(): ?string
317    {
318        return $this->container['id'];
319    }
320
321    /**
322     * Sets id.
323     *
324     * @param string $id a stable privacy-preserving identifier for a given proximity zone
325     *
326     */
327    public function setId(string $id): self
328    {
329        $this->container['id'] = $id;
330
331        return $this;
332    }
333
334    /**
335     * Gets precision_radius.
336     *
337     */
338    public function getPrecisionRadius(): ?int
339    {
340        return $this->container['precision_radius'];
341    }
342
343    /**
344     * Sets precision_radius.
345     *
346     * @param int $precision_radius the radius of the proximity zone’s precision level, in meters
347     *
348     */
349    public function setPrecisionRadius(int $precision_radius): self
350    {
351        $this->container['precision_radius'] = $precision_radius;
352
353        return $this;
354    }
355
356    /**
357     * Gets confidence.
358     *
359     */
360    public function getConfidence(): ?float
361    {
362        return $this->container['confidence'];
363    }
364
365    /**
366     * Sets confidence.
367     *
368     * @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.
369     *
370     */
371    public function setConfidence(float $confidence): self
372    {
373        if ($confidence > 1) {
374            throw new \InvalidArgumentException('invalid value for $confidence when calling Proximity., must be smaller than or equal to 1.');
375        }
376        if ($confidence < 0) {
377            throw new \InvalidArgumentException('invalid value for $confidence when calling Proximity., must be bigger than or equal to 0.');
378        }
379
380        $this->container['confidence'] = $confidence;
381
382        return $this;
383    }
384
385    /**
386     * Returns true if offset exists. False otherwise.
387     *
388     * @param int|string $offset Offset
389     *
390     */
391    public function offsetExists(mixed $offset): bool
392    {
393        return isset($this->container[$offset]);
394    }
395
396    /**
397     * Gets offset.
398     *
399     * @param int|string $offset Offset
400     *
401     * @return mixed|null
402     */
403    #[\ReturnTypeWillChange]
404    public function offsetGet(mixed $offset): mixed
405    {
406        return $this->container[$offset] ?? null;
407    }
408
409    /**
410     * Sets value based on offset.
411     *
412     * @param int|null $offset Offset
413     * @param mixed    $value  Value to be set
414     *
415     */
416    public function offsetSet(mixed $offset, mixed $value): void
417    {
418        if (is_null($offset)) {
419            $this->container[] = $value;
420        } else {
421            $this->container[$offset] = $value;
422        }
423    }
424
425    /**
426     * Unsets offset.
427     *
428     * @param int|string $offset Offset
429     *
430     */
431    public function offsetUnset(mixed $offset): void
432    {
433        unset($this->container[$offset]);
434    }
435
436    /**
437     * Serializes the object to a value that can be serialized natively by json_encode().
438     *
439     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
440     *
441     * @return mixed returns data which can be serialized by json_encode(), which is a value
442     *               of any type other than a resource
443     */
444    #[\ReturnTypeWillChange]
445    public function jsonSerialize(): mixed
446    {
447        return ObjectSerializer::sanitizeForSerialization($this);
448    }
449
450    /**
451     * Gets a header-safe presentation of the object.
452     *
453     */
454    public function toHeaderValue(): string
455    {
456        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
457    }
458
459    /**
460     * Array of nullable properties.
461     */
462    protected static function openAPINullables(): array
463    {
464        return self::$openAPINullables;
465    }
466
467    /**
468     * Array of nullable field names deliberately set to null.
469     *
470     * @return bool[]
471     */
472    private function getOpenAPINullablesSetToNull(): array
473    {
474        return $this->openAPINullablesSetToNull;
475    }
476
477    /**
478     * Setter - Array of nullable field names deliberately set to null.
479     *
480     * @param bool[] $openAPINullablesSetToNull
481     *
482     * @codeCoverageIgnore
483     */
484    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
485    {
486        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
487    }
488
489    /**
490     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
491     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
492     * $this->openAPINullablesSetToNull array.
493     *
494     * @noinspection PhpSameParameterValueInspection
495     */
496    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
497    {
498        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
499            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
500        }
501
502        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
503    }
504}