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