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