PluginProbe
Plausible Analytics / trunk
Plausible Analytics vtrunk
2.6.1 2.6.0 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 All 52 releases
plausible-analytics / src / Client / lib / Model / Error.php

Error.php in Plausible Analytics trunk, at src/Client/lib/Model/Error.php

393 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Error
4 *
5 * PHP version 7.4
6 *
7 * @category Class
8 * @package Plausible\Analytics\WP\Client
9 * @author OpenAPI Generator team
10 * @link https://openapi-generator.tech
11 */
12
13 /**
14 * Plausible Plugins API
15 *
16 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
17 *
18 * The version of the OpenAPI document: 1.0-rc
19 * Generated by: https://openapi-generator.tech
20 * OpenAPI Generator version: 7.0.1
21 */
22
23 /**
24 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
25 * https://openapi-generator.tech
26 * Do not edit the class manually.
27 */
28
29 namespace Plausible\Analytics\WP\Client\Model;
30
31 use \ArrayAccess;
32 use \Plausible\Analytics\WP\Client\ObjectSerializer;
33
34 /**
35 * Error Class Doc Comment
36 *
37 * @category Class
38 * @description An explanation of an error that occurred within the Plugins API
39 * @package Plausible\Analytics\WP\Client
40 * @author OpenAPI Generator team
41 * @link https://openapi-generator.tech
42 * @implements \ArrayAccess<string, mixed>
43 */
44 class Error implements ModelInterface, ArrayAccess, \JsonSerializable {
45 public const DISCRIMINATOR = null;
46
47 /**
48 * The original name of the model.
49 *
50 * @var string
51 */
52 protected static $openAPIModelName = 'Error';
53
54 /**
55 * Array of property to type mappings. Used for (de)serialization
56 *
57 * @var string[]
58 */
59 protected static $openAPITypes = [
60 'detail' => 'string'
61 ];
62
63 /**
64 * Array of property to format mappings. Used for (de)serialization
65 *
66 * @var string[]
67 * @phpstan-var array<string, string|null>
68 * @psalm-var array<string, string|null>
69 */
70 protected static $openAPIFormats = [
71 'detail' => null
72 ];
73
74 /**
75 * Array of nullable properties. Used for (de)serialization
76 *
77 * @var boolean[]
78 */
79 protected static array $openAPINullables = [
80 'detail' => false
81 ];
82
83 /**
84 * If a nullable field gets set to null, insert it here
85 *
86 * @var boolean[]
87 */
88 protected array $openAPINullablesSetToNull = [];
89
90 /**
91 * Array of property to type mappings. Used for (de)serialization
92 *
93 * @return array
94 */
95 public static function openAPITypes() {
96 return self::$openAPITypes;
97 }
98
99 /**
100 * Array of property to format mappings. Used for (de)serialization
101 *
102 * @return array
103 */
104 public static function openAPIFormats() {
105 return self::$openAPIFormats;
106 }
107
108 /**
109 * Array of nullable properties
110 *
111 * @return array
112 */
113 protected static function openAPINullables(): array {
114 return self::$openAPINullables;
115 }
116
117 /**
118 * Array of nullable field names deliberately set to null
119 *
120 * @return boolean[]
121 */
122 private function getOpenAPINullablesSetToNull(): array {
123 return $this->openAPINullablesSetToNull;
124 }
125
126 /**
127 * Setter - Array of nullable field names deliberately set to null
128 *
129 * @param boolean[] $openAPINullablesSetToNull
130 */
131 private function setOpenAPINullablesSetToNull( array $openAPINullablesSetToNull ): void {
132 $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
133 }
134
135 /**
136 * Checks if a property is nullable
137 *
138 * @param string $property
139 *
140 * @return bool
141 */
142 public static function isNullable( string $property ): bool {
143 return self::openAPINullables()[ $property ] ?? false;
144 }
145
146 /**
147 * Checks if a nullable property is set to null.
148 *
149 * @param string $property
150 *
151 * @return bool
152 */
153 public function isNullableSetToNull( string $property ): bool {
154 return in_array( $property, $this->getOpenAPINullablesSetToNull(), true );
155 }
156
157 /**
158 * Array of attributes where the key is the local name,
159 * and the value is the original name
160 *
161 * @var string[]
162 */
163 protected static $attributeMap = [
164 'detail' => 'detail'
165 ];
166
167 /**
168 * Array of attributes to setter functions (for deserialization of responses)
169 *
170 * @var string[]
171 */
172 protected static $setters = [
173 'detail' => 'setDetail'
174 ];
175
176 /**
177 * Array of attributes to getter functions (for serialization of requests)
178 *
179 * @var string[]
180 */
181 protected static $getters = [
182 'detail' => 'getDetail'
183 ];
184
185 /**
186 * Array of attributes where the key is the local name,
187 * and the value is the original name
188 *
189 * @return array
190 */
191 public static function attributeMap() {
192 return self::$attributeMap;
193 }
194
195 /**
196 * Array of attributes to setter functions (for deserialization of responses)
197 *
198 * @return array
199 */
200 public static function setters() {
201 return self::$setters;
202 }
203
204 /**
205 * Array of attributes to getter functions (for serialization of requests)
206 *
207 * @return array
208 */
209 public static function getters() {
210 return self::$getters;
211 }
212
213 /**
214 * The original name of the model.
215 *
216 * @return string
217 */
218 public function getModelName() {
219 return self::$openAPIModelName;
220 }
221
222
223 /**
224 * Associative array for storing property values
225 *
226 * @var mixed[]
227 */
228 protected $container = [];
229
230 /**
231 * Constructor
232 *
233 * @param mixed[]|null $data Associated array of property values
234 * initializing the model
235 */
236 public function __construct( ?array $data = null ) {
237 $this->setIfExists( 'detail', $data ?? [], null );
238 }
239
240 /**
241 * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
242 * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
243 * $this->openAPINullablesSetToNull array
244 *
245 * @param string $variableName
246 * @param array $fields
247 * @param mixed $defaultValue
248 */
249 private function setIfExists( string $variableName, array $fields, $defaultValue ): void {
250 if ( self::isNullable( $variableName ) && array_key_exists( $variableName, $fields ) && is_null( $fields[ $variableName ] ) ) {
251 $this->openAPINullablesSetToNull[] = $variableName;
252 }
253
254 $this->container[ $variableName ] = $fields[ $variableName ] ?? $defaultValue;
255 }
256
257 /**
258 * Show all the invalid properties with reasons.
259 *
260 * @return array invalid properties with reasons
261 */
262 public function listInvalidProperties() {
263 $invalidProperties = [];
264
265 if ( $this->container['detail'] === null ) {
266 $invalidProperties[] = "'detail' can't be null";
267 }
268
269 return $invalidProperties;
270 }
271
272 /**
273 * Validate all the properties in the model
274 * return true if all passed
275 *
276 * @return bool True if all properties are valid
277 */
278 public function valid() {
279 return count( $this->listInvalidProperties()) === 0;
280 }
281
282
283 /**
284 * Gets detail
285 *
286 * @return string
287 */
288 public function getDetail() {
289 return $this->container['detail'];
290 }
291
292 /**
293 * Sets detail
294 *
295 * @param string $detail detail
296 *
297 * @return self
298 */
299 public function setDetail( $detail ) {
300 if ( is_null( $detail ) ) {
301 throw new \InvalidArgumentException( 'non-nullable detail cannot be null' );
302 }
303 $this->container['detail'] = $detail;
304
305 return $this;
306 }
307
308 /**
309 * Returns true if offset exists. False otherwise.
310 *
311 * @param integer $offset Offset
312 *
313 * @return boolean
314 */
315 public function offsetExists( $offset ): bool {
316 return isset( $this->container[ $offset ] );
317 }
318
319 /**
320 * Gets offset.
321 *
322 * @param integer $offset Offset
323 *
324 * @return mixed|null
325 */
326 #[\ReturnTypeWillChange]
327 public function offsetGet( $offset ) {
328 return $this->container[ $offset ] ?? null;
329 }
330
331 /**
332 * Sets value based on offset.
333 *
334 * @param int|null $offset Offset
335 * @param mixed $value Value to be set
336 *
337 * @return void
338 */
339 public function offsetSet( $offset, $value ): void {
340 if ( is_null( $offset ) ) {
341 $this->container[] = $value;
342 } else {
343 $this->container[ $offset ] = $value;
344 }
345 }
346
347 /**
348 * Unsets offset.
349 *
350 * @param integer $offset Offset
351 *
352 * @return void
353 */
354 public function offsetUnset( $offset ): void {
355 unset( $this->container[ $offset ] );
356 }
357
358 /**
359 * Serializes the object to a value that can be serialized natively by json_encode().
360 * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
361 *
362 * @return mixed Returns data which can be serialized by json_encode(), which is a value
363 * of any type other than a resource.
364 */
365 #[\ReturnTypeWillChange]
366 public function jsonSerialize() {
367 return ObjectSerializer::sanitizeForSerialization($this );
368 }
369
370 /**
371 * Gets the string presentation of the object
372 *
373 * @return string
374 */
375 public function __toString() {
376 return json_encode(
377 ObjectSerializer::sanitizeForSerialization( $this ),
378 JSON_PRETTY_PRINT
379 );
380 }
381
382 /**
383 * Gets a header-safe presentation of the object
384 *
385 * @return string
386 */
387 public function toHeaderValue() {
388 return json_encode( ObjectSerializer::sanitizeForSerialization($this));
389 }
390 }
391
392
393