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