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