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