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