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