Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.31% covered (success)
95.31%
61 / 64
94.59% covered (success)
94.59%
35 / 37
CRAP
0.00% covered (danger)
0.00%
0 / 1
EventRuleAction
95.31% covered (success)
95.31%
61 / 64
94.59% covered (success)
94.59%
35 / 37
44
0.00% covered (danger)
0.00%
0 / 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
83.33% covered (warning)
83.33%
5 / 6
0.00% covered (danger)
0.00%
0 / 1
3.04
 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
 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.
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 * 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        if (null === $this->container['type']) {
293            $invalidProperties[] = "'type' can't be null";
294        }
295
296        return $invalidProperties;
297    }
298
299    /**
300     * Validate all the properties in the model
301     * return true if all passed.
302     *
303     * @return bool True if all properties are valid
304     */
305    public function valid(): bool
306    {
307        return 0 === count($this->listInvalidProperties());
308    }
309
310    /**
311     * Gets ruleset_id.
312     *
313     */
314    public function getRulesetId(): ?string
315    {
316        return $this->container['ruleset_id'];
317    }
318
319    /**
320     * Sets ruleset_id.
321     *
322     * @param string $ruleset_id the ID of the evaluated ruleset
323     *
324     */
325    public function setRulesetId(string $ruleset_id): self
326    {
327        $this->container['ruleset_id'] = $ruleset_id;
328
329        return $this;
330    }
331
332    /**
333     * Gets rule_id.
334     *
335     */
336    public function getRuleId(): ?string
337    {
338        return $this->container['rule_id'];
339    }
340
341    /**
342     * Sets rule_id.
343     *
344     * @param string $rule_id the ID of the rule that matched the identification event
345     *
346     */
347    public function setRuleId(string $rule_id): self
348    {
349        $this->container['rule_id'] = $rule_id;
350
351        return $this;
352    }
353
354    /**
355     * Gets rule_expression.
356     *
357     */
358    public function getRuleExpression(): ?string
359    {
360        return $this->container['rule_expression'];
361    }
362
363    /**
364     * Sets rule_expression.
365     *
366     * @param string $rule_expression the expression of the rule that matched the identification event
367     *
368     */
369    public function setRuleExpression(string $rule_expression): self
370    {
371        $this->container['rule_expression'] = $rule_expression;
372
373        return $this;
374    }
375
376    /**
377     * Gets type.
378     *
379     */
380    public function getType(): ?RuleActionType
381    {
382        return $this->container['type'];
383    }
384
385    /**
386     * Sets type.
387     *
388     * @param RuleActionType $type type
389     *
390     */
391    public function setType(RuleActionType $type): self
392    {
393        $this->container['type'] = $type;
394
395        return $this;
396    }
397
398    /**
399     * Gets request_header_modifications.
400     *
401     */
402    public function getRequestHeaderModifications(): ?RequestHeaderModifications
403    {
404        return $this->container['request_header_modifications'];
405    }
406
407    /**
408     * Sets request_header_modifications.
409     *
410     * @param RequestHeaderModifications $request_header_modifications request_header_modifications
411     *
412     */
413    public function setRequestHeaderModifications(RequestHeaderModifications $request_header_modifications): self
414    {
415        $this->container['request_header_modifications'] = $request_header_modifications;
416
417        return $this;
418    }
419
420    /**
421     * Gets status_code.
422     *
423     */
424    public function getStatusCode(): ?int
425    {
426        return $this->container['status_code'];
427    }
428
429    /**
430     * Sets status_code.
431     *
432     * @param int $status_code a valid HTTP status code
433     *
434     */
435    public function setStatusCode(int $status_code): self
436    {
437        $this->container['status_code'] = $status_code;
438
439        return $this;
440    }
441
442    /**
443     * Gets headers.
444     *
445     * @return RuleActionHeaderField[]|null
446     */
447    public function getHeaders(): ?array
448    {
449        return $this->container['headers'];
450    }
451
452    /**
453     * Sets headers.
454     *
455     * @param RuleActionHeaderField[] $headers a list of headers to send
456     *
457     */
458    public function setHeaders(array $headers): self
459    {
460        $this->container['headers'] = $headers;
461
462        return $this;
463    }
464
465    /**
466     * Gets body.
467     *
468     */
469    public function getBody(): ?string
470    {
471        return $this->container['body'];
472    }
473
474    /**
475     * Sets body.
476     *
477     * @param string $body the response body to send to the client
478     *
479     */
480    public function setBody(string $body): self
481    {
482        $this->container['body'] = $body;
483
484        return $this;
485    }
486
487    /**
488     * Returns true if offset exists. False otherwise.
489     *
490     * @param int|string $offset Offset
491     *
492     */
493    public function offsetExists(mixed $offset): bool
494    {
495        return isset($this->container[$offset]);
496    }
497
498    /**
499     * Gets offset.
500     *
501     * @param int|string $offset Offset
502     *
503     * @return mixed|null
504     */
505    #[\ReturnTypeWillChange]
506    public function offsetGet(mixed $offset): mixed
507    {
508        return $this->container[$offset] ?? null;
509    }
510
511    /**
512     * Sets value based on offset.
513     *
514     * @param int|null $offset Offset
515     * @param mixed    $value  Value to be set
516     *
517     */
518    public function offsetSet(mixed $offset, mixed $value): void
519    {
520        if (is_null($offset)) {
521            $this->container[] = $value;
522        } else {
523            $this->container[$offset] = $value;
524        }
525    }
526
527    /**
528     * Unsets offset.
529     *
530     * @param int|string $offset Offset
531     *
532     */
533    public function offsetUnset(mixed $offset): void
534    {
535        unset($this->container[$offset]);
536    }
537
538    /**
539     * Serializes the object to a value that can be serialized natively by json_encode().
540     *
541     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
542     *
543     * @return mixed returns data which can be serialized by json_encode(), which is a value
544     *               of any type other than a resource
545     */
546    #[\ReturnTypeWillChange]
547    public function jsonSerialize(): mixed
548    {
549        return ObjectSerializer::sanitizeForSerialization($this);
550    }
551
552    /**
553     * Gets a header-safe presentation of the object.
554     *
555     */
556    public function toHeaderValue(): string
557    {
558        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
559    }
560
561    /**
562     * Array of nullable properties.
563     */
564    protected static function openAPINullables(): array
565    {
566        return self::$openAPINullables;
567    }
568
569    /**
570     * Array of nullable field names deliberately set to null.
571     *
572     * @return bool[]
573     */
574    private function getOpenAPINullablesSetToNull(): array
575    {
576        return $this->openAPINullablesSetToNull;
577    }
578
579    /**
580     * Setter - Array of nullable field names deliberately set to null.
581     *
582     * @param bool[] $openAPINullablesSetToNull
583     *
584     * @codeCoverageIgnore
585     */
586    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
587    {
588        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
589    }
590
591    /**
592     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
593     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
594     * $this->openAPINullablesSetToNull array.
595     *
596     * @noinspection PhpSameParameterValueInspection
597     */
598    private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
599    {
600        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
601            $this->openAPINullablesSetToNull[] = $variableName; // @codeCoverageIgnore
602        }
603
604        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
605    }
606}