Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
62 / 62
100.00% covered (success)
100.00%
37 / 37
CRAP
100.00% covered (success)
100.00%
1 / 1
EventRuleAction
100.00% covered (success)
100.00%
62 / 62
100.00% covered (success)
100.00%
37 / 37
44
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
9 / 9
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
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
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getStatusCode
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setStatusCode
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getHeaders
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHeaders
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getBody
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setBody
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 * EventRuleAction.
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. The API also supports collection of Automation Intelligence for requests to your server in edge, pre-origin, or middleware contexts.
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.23.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 * Describes the action the client should take, according to the rule in the ruleset that matched the event. When getting an event by event ID, the rule_action will only be included when the ruleset_id query parameter is specified.
36 *
37 * @category Class
38 *
39 * @description Describes the action the client should take, according to the rule in the ruleset that matched the event. When getting an event by event ID, the rule_action will only be included when the ruleset_id query parameter is specified.
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 EventRuleAction implements ModelInterface, \ArrayAccess, \JsonSerializable
51{
52    public const DISCRIMINATOR = 'type';
53
54    /**
55     * The original name of the model.
56     *
57     */
58    protected static string $openAPIModelName = 'EventRuleAction';
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        'status_code' => 'int',
72        'headers' => '\Fingerprint\ServerSdk\Model\RuleActionHeaderField[]',
73        'body' => 'string',
74    ];
75
76    /**
77     * Array of property to format mappings. Used for (de)serialization.
78     *
79     * @var string[]
80     *
81     * @phpstan-var array<string, string|null>
82     *
83     * @psalm-var array<string, string|null>
84     */
85    protected static array $openAPIFormats = [
86        'ruleset_id' => null,
87        'rule_id' => null,
88        'rule_expression' => null,
89        'type' => null,
90        'request_header_modifications' => null,
91        'status_code' => null,
92        'headers' => null,
93        'body' => null,
94    ];
95
96    /**
97     * Array of nullable properties. Used for (de)serialization.
98     *
99     * @var bool[]
100     */
101    protected static array $openAPINullables = [
102        'ruleset_id' => false,
103        'rule_id' => false,
104        'rule_expression' => false,
105        'type' => false,
106        'request_header_modifications' => false,
107        'status_code' => false,
108        'headers' => false,
109        'body' => false,
110    ];
111
112    /**
113     * If a nullable field gets set to null, insert it here.
114     *
115     * @var bool[]
116     */
117    protected array $openAPINullablesSetToNull = [];
118
119    /**
120     * Array of attributes where the key is the local name,
121     * and the value is the original name.
122     *
123     * @var string[]
124     */
125    protected static array $attributeMap = [
126        'ruleset_id' => 'ruleset_id',
127        'rule_id' => 'rule_id',
128        'rule_expression' => 'rule_expression',
129        'type' => 'type',
130        'request_header_modifications' => 'request_header_modifications',
131        'status_code' => 'status_code',
132        'headers' => 'headers',
133        'body' => 'body',
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        'ruleset_id' => 'setRulesetId',
143        'rule_id' => 'setRuleId',
144        'rule_expression' => 'setRuleExpression',
145        'type' => 'setType',
146        'request_header_modifications' => 'setRequestHeaderModifications',
147        'status_code' => 'setStatusCode',
148        'headers' => 'setHeaders',
149        'body' => 'setBody',
150    ];
151
152    /**
153     * Array of attributes to getter functions (for serialization of requests).
154     *
155     * @var string[]
156     */
157    protected static array $getters = [
158        'ruleset_id' => 'getRulesetId',
159        'rule_id' => 'getRuleId',
160        'rule_expression' => 'getRuleExpression',
161        'type' => 'getType',
162        'request_header_modifications' => 'getRequestHeaderModifications',
163        'status_code' => 'getStatusCode',
164        'headers' => 'getHeaders',
165        'body' => 'getBody',
166    ];
167
168    /**
169     * Associative array for storing property values.
170     */
171    protected array $container = [];
172
173    /**
174     * Constructor.
175     *
176     * @param array|null $data Associated array of property values
177     *                         initializing the model
178     *
179     * @noinspection DuplicatedCode
180     */
181    public function __construct(?array $data = null)
182    {
183        $this->setIfExists('ruleset_id', $data ?? [], null);
184        $this->setIfExists('rule_id', $data ?? [], null);
185        $this->setIfExists('rule_expression', $data ?? [], null);
186        $this->setIfExists('type', $data ?? [], null);
187        $this->setIfExists('request_header_modifications', $data ?? [], null);
188        $this->setIfExists('status_code', $data ?? [], null);
189        $this->setIfExists('headers', $data ?? [], null);
190        $this->setIfExists('body', $data ?? [], null);
191
192        // Initialize discriminator property with the model name.
193        $this->container['type'] = static::$openAPIModelName;
194    }
195
196    /**
197     * Gets the string presentation of the object.
198     *
199     */
200    public function __toString(): string
201    {
202        return json_encode(
203            ObjectSerializer::sanitizeForSerialization($this),
204            JSON_PRETTY_PRINT
205        );
206    }
207
208    /**
209     * Array of property to type mappings. Used for (de)serialization.
210     *
211     */
212    public static function openAPITypes(): array
213    {
214        return self::$openAPITypes;
215    }
216
217    /**
218     * Array of property to format mappings. Used for (de)serialization.
219     */
220    public static function openAPIFormats(): array
221    {
222        return self::$openAPIFormats;
223    }
224
225    /**
226     * Checks if a property is nullable.
227     *
228     */
229    public static function isNullable(string $property): bool
230    {
231        return self::openAPINullables()[$property] ?? false;
232    }
233
234    /**
235     * Checks if a nullable property is set to null.
236     *
237     */
238    public function isNullableSetToNull(string $property): bool
239    {
240        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
241    }
242
243    /**
244     * Array of attributes where the key is the local name,
245     * and the value is the original name.
246     *
247     */
248    public static function attributeMap(): array
249    {
250        return self::$attributeMap;
251    }
252
253    /**
254     * Array of attributes to setter functions (for deserialization of responses).
255     *
256     */
257    public static function setters(): array
258    {
259        return self::$setters;
260    }
261
262    /**
263     * Array of attributes to getter functions (for serialization of requests).
264     *
265     */
266    public static function getters(): array
267    {
268        return self::$getters;
269    }
270
271    /**
272     * The original name of the model.
273     *
274     */
275    public function getModelName(): string
276    {
277        return self::$openAPIModelName;
278    }
279
280    /**
281     * Show all the invalid properties with reasons.
282     *
283     * @return array invalid properties with reasons
284     */
285    public function listInvalidProperties(): array
286    {
287        $invalidProperties = [];
288
289        if (null === $this->container['ruleset_id']) {
290            $invalidProperties[] = "'ruleset_id' can't be null";
291        }
292        // @codeCoverageIgnoreStart
293        if (null === $this->container['type']) {
294            $invalidProperties[] = "'type' can't be null";
295        }
296        // @codeCoverageIgnoreEnd
297
298        return $invalidProperties;
299    }
300
301    /**
302     * Validate all the properties in the model
303     * return true if all passed.
304     *
305     * @return bool True if all properties are valid
306     */
307    public function valid(): bool
308    {
309        return 0 === count($this->listInvalidProperties());
310    }
311
312    /**
313     * Gets ruleset_id.
314     *
315     */
316    public function getRulesetId(): ?string
317    {
318        return $this->container['ruleset_id'];
319    }
320
321    /**
322     * Sets ruleset_id.
323     *
324     * @param string $ruleset_id the ID of the evaluated ruleset
325     *
326     */
327    public function setRulesetId(string $ruleset_id): self
328    {
329        $this->container['ruleset_id'] = $ruleset_id;
330
331        return $this;
332    }
333
334    /**
335     * Gets rule_id.
336     *
337     */
338    public function getRuleId(): ?string
339    {
340        return $this->container['rule_id'];
341    }
342
343    /**
344     * Sets rule_id.
345     *
346     * @param string $rule_id the ID of the rule that matched the identification event
347     *
348     */
349    public function setRuleId(string $rule_id): self
350    {
351        $this->container['rule_id'] = $rule_id;
352
353        return $this;
354    }
355
356    /**
357     * Gets rule_expression.
358     *
359     */
360    public function getRuleExpression(): ?string
361    {
362        return $this->container['rule_expression'];
363    }
364
365    /**
366     * Sets rule_expression.
367     *
368     * @param string $rule_expression the expression of the rule that matched the identification event
369     *
370     */
371    public function setRuleExpression(string $rule_expression): self
372    {
373        $this->container['rule_expression'] = $rule_expression;
374
375        return $this;
376    }
377
378    /**
379     * Gets type.
380     *
381     */
382    public function getType(): RuleActionType|string|null
383    {
384        return $this->container['type'];
385    }
386
387    /**
388     * Sets type.
389     *
390     * @param RuleActionType|string $type type
391     *
392     */
393    public function setType(RuleActionType|string $type): self
394    {
395        $this->container['type'] = $type;
396
397        return $this;
398    }
399
400    /**
401     * Gets request_header_modifications.
402     *
403     */
404    public function getRequestHeaderModifications(): ?RequestHeaderModifications
405    {
406        return $this->container['request_header_modifications'];
407    }
408
409    /**
410     * Sets request_header_modifications.
411     *
412     * @param RequestHeaderModifications $request_header_modifications request_header_modifications
413     *
414     */
415    public function setRequestHeaderModifications(RequestHeaderModifications $request_header_modifications): self
416    {
417        $this->container['request_header_modifications'] = $request_header_modifications;
418
419        return $this;
420    }
421
422    /**
423     * Gets status_code.
424     *
425     */
426    public function getStatusCode(): ?int
427    {
428        return $this->container['status_code'];
429    }
430
431    /**
432     * Sets status_code.
433     *
434     * @param int $status_code a valid HTTP status code
435     *
436     */
437    public function setStatusCode(int $status_code): self
438    {
439        $this->container['status_code'] = $status_code;
440
441        return $this;
442    }
443
444    /**
445     * Gets headers.
446     *
447     * @return RuleActionHeaderField[]|null
448     */
449    public function getHeaders(): ?array
450    {
451        return $this->container['headers'];
452    }
453
454    /**
455     * Sets headers.
456     *
457     * @param RuleActionHeaderField[] $headers a list of headers to send
458     *
459     */
460    public function setHeaders(array $headers): self
461    {
462        $this->container['headers'] = $headers;
463
464        return $this;
465    }
466
467    /**
468     * Gets body.
469     *
470     */
471    public function getBody(): ?string
472    {
473        return $this->container['body'];
474    }
475
476    /**
477     * Sets body.
478     *
479     * @param string $body the response body to send to the client
480     *
481     */
482    public function setBody(string $body): self
483    {
484        $this->container['body'] = $body;
485
486        return $this;
487    }
488
489    /**
490     * Returns true if offset exists. False otherwise.
491     *
492     * @param int|string $offset Offset
493     *
494     */
495    public function offsetExists(mixed $offset): bool
496    {
497        return isset($this->container[$offset]);
498    }
499
500    /**
501     * Gets offset.
502     *
503     * @param int|string $offset Offset
504     *
505     * @return mixed|null
506     */
507    #[\ReturnTypeWillChange]
508    public function offsetGet(mixed $offset): mixed
509    {
510        return $this->container[$offset] ?? null;
511    }
512
513    /**
514     * Sets value based on offset.
515     *
516     * @param int|null $offset Offset
517     * @param mixed    $value  Value to be set
518     *
519     */
520    public function offsetSet(mixed $offset, mixed $value): void
521    {
522        if (is_null($offset)) {
523            $this->container[] = $value;
524        } else {
525            $this->container[$offset] = $value;
526        }
527    }
528
529    /**
530     * Unsets offset.
531     *
532     * @param int|string $offset Offset
533     *
534     */
535    public function offsetUnset(mixed $offset): void
536    {
537        unset($this->container[$offset]);
538    }
539
540    /**
541     * Serializes the object to a value that can be serialized natively by json_encode().
542     *
543     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
544     *
545     * @return mixed returns data which can be serialized by json_encode(), which is a value
546     *               of any type other than a resource
547     */
548    #[\ReturnTypeWillChange]
549    public function jsonSerialize(): mixed
550    {
551        return ObjectSerializer::sanitizeForSerialization($this);
552    }
553
554    /**
555     * Gets a header-safe presentation of the object.
556     *
557     */
558    public function toHeaderValue(): string
559    {
560        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
561    }
562
563    /**
564     * Array of nullable properties.
565     */
566    protected static function openAPINullables(): array
567    {
568        return self::$openAPINullables;
569    }
570
571    /**
572     * Array of nullable field names deliberately set to null.
573     *
574     * @return bool[]
575     */
576    private function getOpenAPINullablesSetToNull(): array
577    {
578        return $this->openAPINullablesSetToNull;
579    }
580
581    /**
582     * Setter - Array of nullable field names deliberately set to null.
583     *
584     * @param bool[] $openAPINullablesSetToNull
585     *
586     * @codeCoverageIgnore
587     */
588    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
589    {
590        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
591    }
592
593    /**
594     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
595     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
596     * $this->openAPINullablesSetToNull array.
597     *
598     * @noinspection PhpSameParameterValueInspection
599     */
600    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
601    {
602        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
603            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
604        }
605
606        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
607    }
608}