Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
63 / 63
100.00% covered (success)
100.00%
33 / 33
CRAP
100.00% covered (success)
100.00%
1 / 1
BrowserDetails
100.00% covered (success)
100.00%
63 / 63
100.00% covered (success)
100.00%
33 / 33
44
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
6 / 6
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
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
7
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getBrowserName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBrowserName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getBrowserMajorVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBrowserMajorVersion
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getBrowserFullVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBrowserFullVersion
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getOs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setOs
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getOsVersion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setOsVersion
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getDevice
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDevice
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 * BrowserDetails.
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 * BrowserDetails 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 BrowserDetails 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 = 'BrowserDetails';
57
58    /**
59     * Array of property to type mappings. Used for (de)serialization.
60     *
61     * @var string[]
62     */
63    protected static array $openAPITypes = [
64        'browser_name' => 'string',
65        'browser_major_version' => 'string',
66        'browser_full_version' => 'string',
67        'os' => 'string',
68        'os_version' => 'string',
69        'device' => 'string',
70    ];
71
72    /**
73     * Array of property to format mappings. Used for (de)serialization.
74     *
75     * @var string[]
76     *
77     * @phpstan-var array<string, string|null>
78     *
79     * @psalm-var array<string, string|null>
80     */
81    protected static array $openAPIFormats = [
82        'browser_name' => null,
83        'browser_major_version' => null,
84        'browser_full_version' => null,
85        'os' => null,
86        'os_version' => null,
87        'device' => null,
88    ];
89
90    /**
91     * Array of nullable properties. Used for (de)serialization.
92     *
93     * @var bool[]
94     */
95    protected static array $openAPINullables = [
96        'browser_name' => false,
97        'browser_major_version' => false,
98        'browser_full_version' => false,
99        'os' => false,
100        'os_version' => false,
101        'device' => false,
102    ];
103
104    /**
105     * If a nullable field gets set to null, insert it here.
106     *
107     * @var bool[]
108     */
109    protected array $openAPINullablesSetToNull = [];
110
111    /**
112     * Array of attributes where the key is the local name,
113     * and the value is the original name.
114     *
115     * @var string[]
116     */
117    protected static array $attributeMap = [
118        'browser_name' => 'browser_name',
119        'browser_major_version' => 'browser_major_version',
120        'browser_full_version' => 'browser_full_version',
121        'os' => 'os',
122        'os_version' => 'os_version',
123        'device' => 'device',
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        'browser_name' => 'setBrowserName',
133        'browser_major_version' => 'setBrowserMajorVersion',
134        'browser_full_version' => 'setBrowserFullVersion',
135        'os' => 'setOs',
136        'os_version' => 'setOsVersion',
137        'device' => 'setDevice',
138    ];
139
140    /**
141     * Array of attributes to getter functions (for serialization of requests).
142     *
143     * @var string[]
144     */
145    protected static array $getters = [
146        'browser_name' => 'getBrowserName',
147        'browser_major_version' => 'getBrowserMajorVersion',
148        'browser_full_version' => 'getBrowserFullVersion',
149        'os' => 'getOs',
150        'os_version' => 'getOsVersion',
151        'device' => 'getDevice',
152    ];
153
154    /**
155     * Associative array for storing property values.
156     */
157    protected array $container = [];
158
159    /**
160     * Constructor.
161     *
162     * @param array|null $data Associated array of property values
163     *                         initializing the model
164     *
165     * @noinspection DuplicatedCode
166     */
167    public function __construct(?array $data = null)
168    {
169        $this->setIfExists('browser_name', $data ?? [], null);
170        $this->setIfExists('browser_major_version', $data ?? [], null);
171        $this->setIfExists('browser_full_version', $data ?? [], null);
172        $this->setIfExists('os', $data ?? [], null);
173        $this->setIfExists('os_version', $data ?? [], null);
174        $this->setIfExists('device', $data ?? [], null);
175    }
176
177    /**
178     * Gets the string presentation of the object.
179     *
180     */
181    public function __toString(): string
182    {
183        return json_encode(
184            ObjectSerializer::sanitizeForSerialization($this),
185            JSON_PRETTY_PRINT
186        );
187    }
188
189    /**
190     * Array of property to type mappings. Used for (de)serialization.
191     *
192     */
193    public static function openAPITypes(): array
194    {
195        return self::$openAPITypes;
196    }
197
198    /**
199     * Array of property to format mappings. Used for (de)serialization.
200     */
201    public static function openAPIFormats(): array
202    {
203        return self::$openAPIFormats;
204    }
205
206    /**
207     * Checks if a property is nullable.
208     *
209     */
210    public static function isNullable(string $property): bool
211    {
212        return self::openAPINullables()[$property] ?? false;
213    }
214
215    /**
216     * Checks if a nullable property is set to null.
217     *
218     */
219    public function isNullableSetToNull(string $property): bool
220    {
221        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
222    }
223
224    /**
225     * Array of attributes where the key is the local name,
226     * and the value is the original name.
227     *
228     */
229    public static function attributeMap(): array
230    {
231        return self::$attributeMap;
232    }
233
234    /**
235     * Array of attributes to setter functions (for deserialization of responses).
236     *
237     */
238    public static function setters(): array
239    {
240        return self::$setters;
241    }
242
243    /**
244     * Array of attributes to getter functions (for serialization of requests).
245     *
246     */
247    public static function getters(): array
248    {
249        return self::$getters;
250    }
251
252    /**
253     * The original name of the model.
254     *
255     */
256    public function getModelName(): string
257    {
258        return self::$openAPIModelName;
259    }
260
261    /**
262     * Show all the invalid properties with reasons.
263     *
264     * @return array invalid properties with reasons
265     */
266    public function listInvalidProperties(): array
267    {
268        $invalidProperties = [];
269
270        if (null === $this->container['browser_name']) {
271            $invalidProperties[] = "'browser_name' can't be null";
272        }
273        if (null === $this->container['browser_major_version']) {
274            $invalidProperties[] = "'browser_major_version' can't be null";
275        }
276        if (null === $this->container['browser_full_version']) {
277            $invalidProperties[] = "'browser_full_version' can't be null";
278        }
279        if (null === $this->container['os']) {
280            $invalidProperties[] = "'os' can't be null";
281        }
282        if (null === $this->container['os_version']) {
283            $invalidProperties[] = "'os_version' can't be null";
284        }
285        if (null === $this->container['device']) {
286            $invalidProperties[] = "'device' can't be null";
287        }
288
289        return $invalidProperties;
290    }
291
292    /**
293     * Validate all the properties in the model
294     * return true if all passed.
295     *
296     * @return bool True if all properties are valid
297     */
298    public function valid(): bool
299    {
300        return 0 === count($this->listInvalidProperties());
301    }
302
303    /**
304     * Gets browser_name.
305     *
306     */
307    public function getBrowserName(): ?string
308    {
309        return $this->container['browser_name'];
310    }
311
312    /**
313     * Sets browser_name.
314     *
315     * @param string $browser_name browser_name
316     *
317     */
318    public function setBrowserName(string $browser_name): self
319    {
320        $this->container['browser_name'] = $browser_name;
321
322        return $this;
323    }
324
325    /**
326     * Gets browser_major_version.
327     *
328     */
329    public function getBrowserMajorVersion(): ?string
330    {
331        return $this->container['browser_major_version'];
332    }
333
334    /**
335     * Sets browser_major_version.
336     *
337     * @param string $browser_major_version browser_major_version
338     *
339     */
340    public function setBrowserMajorVersion(string $browser_major_version): self
341    {
342        $this->container['browser_major_version'] = $browser_major_version;
343
344        return $this;
345    }
346
347    /**
348     * Gets browser_full_version.
349     *
350     */
351    public function getBrowserFullVersion(): ?string
352    {
353        return $this->container['browser_full_version'];
354    }
355
356    /**
357     * Sets browser_full_version.
358     *
359     * @param string $browser_full_version browser_full_version
360     *
361     */
362    public function setBrowserFullVersion(string $browser_full_version): self
363    {
364        $this->container['browser_full_version'] = $browser_full_version;
365
366        return $this;
367    }
368
369    /**
370     * Gets os.
371     *
372     */
373    public function getOs(): ?string
374    {
375        return $this->container['os'];
376    }
377
378    /**
379     * Sets os.
380     *
381     * @param string $os os
382     *
383     */
384    public function setOs(string $os): self
385    {
386        $this->container['os'] = $os;
387
388        return $this;
389    }
390
391    /**
392     * Gets os_version.
393     *
394     */
395    public function getOsVersion(): ?string
396    {
397        return $this->container['os_version'];
398    }
399
400    /**
401     * Sets os_version.
402     *
403     * @param string $os_version os_version
404     *
405     */
406    public function setOsVersion(string $os_version): self
407    {
408        $this->container['os_version'] = $os_version;
409
410        return $this;
411    }
412
413    /**
414     * Gets device.
415     *
416     */
417    public function getDevice(): ?string
418    {
419        return $this->container['device'];
420    }
421
422    /**
423     * Sets device.
424     *
425     * @param string $device device
426     *
427     */
428    public function setDevice(string $device): self
429    {
430        $this->container['device'] = $device;
431
432        return $this;
433    }
434
435    /**
436     * Returns true if offset exists. False otherwise.
437     *
438     * @param int|string $offset Offset
439     *
440     */
441    public function offsetExists(mixed $offset): bool
442    {
443        return isset($this->container[$offset]);
444    }
445
446    /**
447     * Gets offset.
448     *
449     * @param int|string $offset Offset
450     *
451     * @return mixed|null
452     */
453    #[\ReturnTypeWillChange]
454    public function offsetGet(mixed $offset): mixed
455    {
456        return $this->container[$offset] ?? null;
457    }
458
459    /**
460     * Sets value based on offset.
461     *
462     * @param int|null $offset Offset
463     * @param mixed    $value  Value to be set
464     *
465     */
466    public function offsetSet(mixed $offset, mixed $value): void
467    {
468        if (is_null($offset)) {
469            $this->container[] = $value;
470        } else {
471            $this->container[$offset] = $value;
472        }
473    }
474
475    /**
476     * Unsets offset.
477     *
478     * @param int|string $offset Offset
479     *
480     */
481    public function offsetUnset(mixed $offset): void
482    {
483        unset($this->container[$offset]);
484    }
485
486    /**
487     * Serializes the object to a value that can be serialized natively by json_encode().
488     *
489     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
490     *
491     * @return mixed returns data which can be serialized by json_encode(), which is a value
492     *               of any type other than a resource
493     */
494    #[\ReturnTypeWillChange]
495    public function jsonSerialize(): mixed
496    {
497        return ObjectSerializer::sanitizeForSerialization($this);
498    }
499
500    /**
501     * Gets a header-safe presentation of the object.
502     *
503     */
504    public function toHeaderValue(): string
505    {
506        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
507    }
508
509    /**
510     * Array of nullable properties.
511     */
512    protected static function openAPINullables(): array
513    {
514        return self::$openAPINullables;
515    }
516
517    /**
518     * Array of nullable field names deliberately set to null.
519     *
520     * @return bool[]
521     */
522    private function getOpenAPINullablesSetToNull(): array
523    {
524        return $this->openAPINullablesSetToNull;
525    }
526
527    /**
528     * Setter - Array of nullable field names deliberately set to null.
529     *
530     * @param bool[] $openAPINullablesSetToNull
531     *
532     * @codeCoverageIgnore
533     */
534    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
535    {
536        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
537    }
538
539    /**
540     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
541     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
542     * $this->openAPINullablesSetToNull array.
543     *
544     * @noinspection PhpSameParameterValueInspection
545     */
546    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
547    {
548        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
549            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
550        }
551
552        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
553    }
554}