Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
104 / 104
100.00% covered (success)
100.00%
35 / 35
CRAP
100.00% covered (success)
100.00%
1 / 1
BotInfo
100.00% covered (success)
100.00%
104 / 104
100.00% covered (success)
100.00%
35 / 35
51
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
 getIdentityAllowableValues
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getConfidenceAllowableValues
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 listInvalidProperties
100.00% covered (success)
100.00%
26 / 26
100.00% covered (success)
100.00%
1 / 1
10
 valid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCategory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setCategory
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getProvider
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setProvider
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getProviderUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setProviderUrl
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getIdentity
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setIdentity
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%
11 / 11
100.00% covered (success)
100.00%
1 / 1
2
 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 * BotInfo.
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 * Extended bot information.
36 *
37 * @category Class
38 *
39 * @description Extended bot information.
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 BotInfo implements ModelInterface, \ArrayAccess, \JsonSerializable
51{
52    public const DISCRIMINATOR = null;
53
54    public const IDENTITY_VERIFIED = 'verified';
55    public const IDENTITY_SIGNED = 'signed';
56    public const IDENTITY_SPOOFED = 'spoofed';
57    public const IDENTITY_UNKNOWN = 'unknown';
58    public const CONFIDENCE_LOW = 'low';
59    public const CONFIDENCE_MEDIUM = 'medium';
60    public const CONFIDENCE_HIGH = 'high';
61
62    /**
63     * The original name of the model.
64     *
65     */
66    protected static string $openAPIModelName = 'BotInfo';
67
68    /**
69     * Array of property to type mappings. Used for (de)serialization.
70     *
71     * @var string[]
72     */
73    protected static array $openAPITypes = [
74        'category' => 'string',
75        'provider' => 'string',
76        'provider_url' => 'string',
77        'name' => 'string',
78        'identity' => 'string',
79        'confidence' => 'string',
80    ];
81
82    /**
83     * Array of property to format mappings. Used for (de)serialization.
84     *
85     * @var string[]
86     *
87     * @phpstan-var array<string, string|null>
88     *
89     * @psalm-var array<string, string|null>
90     */
91    protected static array $openAPIFormats = [
92        'category' => null,
93        'provider' => null,
94        'provider_url' => null,
95        'name' => null,
96        'identity' => null,
97        'confidence' => null,
98    ];
99
100    /**
101     * Array of nullable properties. Used for (de)serialization.
102     *
103     * @var bool[]
104     */
105    protected static array $openAPINullables = [
106        'category' => false,
107        'provider' => false,
108        'provider_url' => false,
109        'name' => false,
110        'identity' => false,
111        'confidence' => false,
112    ];
113
114    /**
115     * If a nullable field gets set to null, insert it here.
116     *
117     * @var bool[]
118     */
119    protected array $openAPINullablesSetToNull = [];
120
121    /**
122     * Array of attributes where the key is the local name,
123     * and the value is the original name.
124     *
125     * @var string[]
126     */
127    protected static array $attributeMap = [
128        'category' => 'category',
129        'provider' => 'provider',
130        'provider_url' => 'provider_url',
131        'name' => 'name',
132        'identity' => 'identity',
133        'confidence' => 'confidence',
134    ];
135
136    /**
137     * Array of attributes to setter functions (for deserialization of responses).
138     *
139     * @var string[]
140     */
141    protected static array $setters = [
142        'category' => 'setCategory',
143        'provider' => 'setProvider',
144        'provider_url' => 'setProviderUrl',
145        'name' => 'setName',
146        'identity' => 'setIdentity',
147        'confidence' => 'setConfidence',
148    ];
149
150    /**
151     * Array of attributes to getter functions (for serialization of requests).
152     *
153     * @var string[]
154     */
155    protected static array $getters = [
156        'category' => 'getCategory',
157        'provider' => 'getProvider',
158        'provider_url' => 'getProviderUrl',
159        'name' => 'getName',
160        'identity' => 'getIdentity',
161        'confidence' => 'getConfidence',
162    ];
163
164    /**
165     * Associative array for storing property values.
166     */
167    protected array $container = [];
168
169    /**
170     * Constructor.
171     *
172     * @param array|null $data Associated array of property values
173     *                         initializing the model
174     *
175     * @noinspection DuplicatedCode
176     */
177    public function __construct(?array $data = null)
178    {
179        $this->setIfExists('category', $data ?? [], null);
180        $this->setIfExists('provider', $data ?? [], null);
181        $this->setIfExists('provider_url', $data ?? [], null);
182        $this->setIfExists('name', $data ?? [], null);
183        $this->setIfExists('identity', $data ?? [], null);
184        $this->setIfExists('confidence', $data ?? [], null);
185    }
186
187    /**
188     * Gets the string presentation of the object.
189     *
190     */
191    public function __toString(): string
192    {
193        return json_encode(
194            ObjectSerializer::sanitizeForSerialization($this),
195            JSON_PRETTY_PRINT
196        );
197    }
198
199    /**
200     * Array of property to type mappings. Used for (de)serialization.
201     *
202     */
203    public static function openAPITypes(): array
204    {
205        return self::$openAPITypes;
206    }
207
208    /**
209     * Array of property to format mappings. Used for (de)serialization.
210     */
211    public static function openAPIFormats(): array
212    {
213        return self::$openAPIFormats;
214    }
215
216    /**
217     * Checks if a property is nullable.
218     *
219     */
220    public static function isNullable(string $property): bool
221    {
222        return self::openAPINullables()[$property] ?? false;
223    }
224
225    /**
226     * Checks if a nullable property is set to null.
227     *
228     */
229    public function isNullableSetToNull(string $property): bool
230    {
231        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
232    }
233
234    /**
235     * Array of attributes where the key is the local name,
236     * and the value is the original name.
237     *
238     */
239    public static function attributeMap(): array
240    {
241        return self::$attributeMap;
242    }
243
244    /**
245     * Array of attributes to setter functions (for deserialization of responses).
246     *
247     */
248    public static function setters(): array
249    {
250        return self::$setters;
251    }
252
253    /**
254     * Array of attributes to getter functions (for serialization of requests).
255     *
256     */
257    public static function getters(): array
258    {
259        return self::$getters;
260    }
261
262    /**
263     * The original name of the model.
264     *
265     */
266    public function getModelName(): string
267    {
268        return self::$openAPIModelName;
269    }
270
271    /**
272     * Gets allowable values of the enum.
273     *
274     * @return string[]
275     */
276    public function getIdentityAllowableValues(): array
277    {
278        return [
279            self::IDENTITY_VERIFIED,
280            self::IDENTITY_SIGNED,
281            self::IDENTITY_SPOOFED,
282            self::IDENTITY_UNKNOWN,
283        ];
284    }
285
286    /**
287     * Gets allowable values of the enum.
288     *
289     * @return string[]
290     */
291    public function getConfidenceAllowableValues(): array
292    {
293        return [
294            self::CONFIDENCE_LOW,
295            self::CONFIDENCE_MEDIUM,
296            self::CONFIDENCE_HIGH,
297        ];
298    }
299
300    /**
301     * Show all the invalid properties with reasons.
302     *
303     * @return array invalid properties with reasons
304     */
305    public function listInvalidProperties(): array
306    {
307        $invalidProperties = [];
308
309        if (null === $this->container['category']) {
310            $invalidProperties[] = "'category' can't be null";
311        }
312        if (null === $this->container['provider']) {
313            $invalidProperties[] = "'provider' can't be null";
314        }
315        if (null === $this->container['name']) {
316            $invalidProperties[] = "'name' can't be null";
317        }
318        if (null === $this->container['identity']) {
319            $invalidProperties[] = "'identity' can't be null";
320        }
321        $allowedValues = $this->getIdentityAllowableValues();
322        if (!is_null($this->container['identity']) && !in_array($this->container['identity'], $allowedValues, true)) {
323            $invalidProperties[] = sprintf(
324                "invalid value '%s' for 'identity', must be one of '%s'",
325                $this->container['identity'],
326                implode("', '", $allowedValues)
327            );
328        }
329
330        if (null === $this->container['confidence']) {
331            $invalidProperties[] = "'confidence' can't be null";
332        }
333        $allowedValues = $this->getConfidenceAllowableValues();
334        if (!is_null($this->container['confidence']) && !in_array($this->container['confidence'], $allowedValues, true)) {
335            $invalidProperties[] = sprintf(
336                "invalid value '%s' for 'confidence', must be one of '%s'",
337                $this->container['confidence'],
338                implode("', '", $allowedValues)
339            );
340        }
341
342        return $invalidProperties;
343    }
344
345    /**
346     * Validate all the properties in the model
347     * return true if all passed.
348     *
349     * @return bool True if all properties are valid
350     */
351    public function valid(): bool
352    {
353        return 0 === count($this->listInvalidProperties());
354    }
355
356    /**
357     * Gets category.
358     *
359     */
360    public function getCategory(): ?string
361    {
362        return $this->container['category'];
363    }
364
365    /**
366     * Sets category.
367     *
368     * @param string $category the type and purpose of the bot
369     *
370     */
371    public function setCategory(string $category): self
372    {
373        $this->container['category'] = $category;
374
375        return $this;
376    }
377
378    /**
379     * Gets provider.
380     *
381     */
382    public function getProvider(): ?string
383    {
384        return $this->container['provider'];
385    }
386
387    /**
388     * Sets provider.
389     *
390     * @param string $provider the organization or company operating the bot
391     *
392     */
393    public function setProvider(string $provider): self
394    {
395        $this->container['provider'] = $provider;
396
397        return $this;
398    }
399
400    /**
401     * Gets provider_url.
402     *
403     */
404    public function getProviderUrl(): ?string
405    {
406        return $this->container['provider_url'];
407    }
408
409    /**
410     * Sets provider_url.
411     *
412     * @param string $provider_url the URL of the bot provider's website
413     *
414     */
415    public function setProviderUrl(string $provider_url): self
416    {
417        $this->container['provider_url'] = $provider_url;
418
419        return $this;
420    }
421
422    /**
423     * Gets name.
424     *
425     */
426    public function getName(): ?string
427    {
428        return $this->container['name'];
429    }
430
431    /**
432     * Sets name.
433     *
434     * @param string $name the specific name or identifier of the bot
435     *
436     */
437    public function setName(string $name): self
438    {
439        $this->container['name'] = $name;
440
441        return $this;
442    }
443
444    /**
445     * Gets identity.
446     *
447     */
448    public function getIdentity(): ?string
449    {
450        return $this->container['identity'];
451    }
452
453    /**
454     * Sets identity.
455     *
456     * @param string $identity The verification status of the bot's identity:  * `verified` - well-known bot with publicly verifiable identity, directed by the bot provider.  * `signed` - bot that signs its platform via Web Bot Auth, directed by the bot provider’s customers.  * `spoofed` - bot that claims a public identity but fails verification.  * `unknown` - bot that does not publish a verifiable identity.
457     *
458     */
459    public function setIdentity(string $identity): self
460    {
461        $allowedValues = $this->getIdentityAllowableValues();
462        if (!in_array($identity, $allowedValues, true)) {
463            throw new \InvalidArgumentException(
464                sprintf(
465                    "Invalid value '%s' for 'identity', must be one of '%s'",
466                    $identity,
467                    implode("', '", $allowedValues)
468                )
469            );
470        }
471        $this->container['identity'] = $identity;
472
473        return $this;
474    }
475
476    /**
477     * Gets confidence.
478     *
479     */
480    public function getConfidence(): ?string
481    {
482        return $this->container['confidence'];
483    }
484
485    /**
486     * Sets confidence.
487     *
488     * @param string $confidence confidence level of the bot identification
489     *
490     */
491    public function setConfidence(string $confidence): self
492    {
493        $allowedValues = $this->getConfidenceAllowableValues();
494        if (!in_array($confidence, $allowedValues, true)) {
495            throw new \InvalidArgumentException(
496                sprintf(
497                    "Invalid value '%s' for 'confidence', must be one of '%s'",
498                    $confidence,
499                    implode("', '", $allowedValues)
500                )
501            );
502        }
503        $this->container['confidence'] = $confidence;
504
505        return $this;
506    }
507
508    /**
509     * Returns true if offset exists. False otherwise.
510     *
511     * @param int|string $offset Offset
512     *
513     */
514    public function offsetExists(mixed $offset): bool
515    {
516        return isset($this->container[$offset]);
517    }
518
519    /**
520     * Gets offset.
521     *
522     * @param int|string $offset Offset
523     *
524     * @return mixed|null
525     */
526    #[\ReturnTypeWillChange]
527    public function offsetGet(mixed $offset): mixed
528    {
529        return $this->container[$offset] ?? null;
530    }
531
532    /**
533     * Sets value based on offset.
534     *
535     * @param int|null $offset Offset
536     * @param mixed    $value  Value to be set
537     *
538     */
539    public function offsetSet(mixed $offset, mixed $value): void
540    {
541        if (is_null($offset)) {
542            $this->container[] = $value;
543        } else {
544            $this->container[$offset] = $value;
545        }
546    }
547
548    /**
549     * Unsets offset.
550     *
551     * @param int|string $offset Offset
552     *
553     */
554    public function offsetUnset(mixed $offset): void
555    {
556        unset($this->container[$offset]);
557    }
558
559    /**
560     * Serializes the object to a value that can be serialized natively by json_encode().
561     *
562     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
563     *
564     * @return mixed returns data which can be serialized by json_encode(), which is a value
565     *               of any type other than a resource
566     */
567    #[\ReturnTypeWillChange]
568    public function jsonSerialize(): mixed
569    {
570        return ObjectSerializer::sanitizeForSerialization($this);
571    }
572
573    /**
574     * Gets a header-safe presentation of the object.
575     *
576     */
577    public function toHeaderValue(): string
578    {
579        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
580    }
581
582    /**
583     * Array of nullable properties.
584     */
585    protected static function openAPINullables(): array
586    {
587        return self::$openAPINullables;
588    }
589
590    /**
591     * Array of nullable field names deliberately set to null.
592     *
593     * @return bool[]
594     */
595    private function getOpenAPINullablesSetToNull(): array
596    {
597        return $this->openAPINullablesSetToNull;
598    }
599
600    /**
601     * Setter - Array of nullable field names deliberately set to null.
602     *
603     * @param bool[] $openAPINullablesSetToNull
604     *
605     * @codeCoverageIgnore
606     */
607    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
608    {
609        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
610    }
611
612    /**
613     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
614     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
615     * $this->openAPINullablesSetToNull array.
616     *
617     * @noinspection PhpSameParameterValueInspection
618     */
619    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
620    {
621        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
622            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
623        }
624
625        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
626    }
627}