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 / Link.php

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

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