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

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

407 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * GoalCreateRequestBulkGetOrCreate
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 * GoalCreateRequestBulkGetOrCreate Class Doc Comment
36 *
37 * @category Class
38 * @description Bulk goal creation request
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 GoalCreateRequestBulkGetOrCreate 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 = 'Goal_CreateRequest_BulkGetOrCreate';
53
54 /**
55 * Array of property to type mappings. Used for (de)serialization
56 *
57 * @var string[]
58 */
59 protected static $openAPITypes = [
60 'goals' => '\Plausible\Analytics\WP\Client\Model\GoalCreateRequestBulkGetOrCreateGoalsInner[]'
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 'goals' => null
72 ];
73
74 /**
75 * Array of nullable properties. Used for (de)serialization
76 *
77 * @var boolean[]
78 */
79 protected static array $openAPINullables = [
80 'goals' => 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 'goals' => 'goals'
165 ];
166
167 /**
168 * Array of attributes to setter functions (for deserialization of responses)
169 *
170 * @var string[]
171 */
172 protected static $setters = [
173 'goals' => 'setGoals'
174 ];
175
176 /**
177 * Array of attributes to getter functions (for serialization of requests)
178 *
179 * @var string[]
180 */
181 protected static $getters = [
182 'goals' => 'getGoals'
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( 'goals', $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['goals'] === null ) {
266 $invalidProperties[] = "'goals' can't be null";
267 }
268 if ( ( count( $this->container['goals'] ) > 8 ) ) {
269 $invalidProperties[] = "invalid value for 'goals', number of items must be less than or equal to 8.";
270 }
271
272 if ( ( count( $this->container['goals'] ) < 1 ) ) {
273 $invalidProperties[] = "invalid value for 'goals', number of items must be greater than or equal to 1.";
274 }
275
276 return $invalidProperties;
277 }
278
279 /**
280 * Validate all the properties in the model
281 * return true if all passed
282 *
283 * @return bool True if all properties are valid
284 */
285 public function valid() {
286 return count( $this->listInvalidProperties()) === 0;
287 }
288
289
290 /**
291 * Gets goals
292 *
293 * @return \Plausible\Analytics\WP\Client\Model\GoalCreateRequestBulkGetOrCreateGoalsInner[]
294 */
295 public function getGoals() {
296 return $this->container['goals'];
297 }
298
299 /**
300 * Sets goals
301 *
302 * @param \Plausible\Analytics\WP\Client\Model\GoalCreateRequestBulkGetOrCreateGoalsInner[] $goals goals
303 *
304 * @return self
305 */
306 public function setGoals( $goals ) {
307 if ( is_null( $goals ) ) {
308 throw new \InvalidArgumentException( 'non-nullable goals cannot be null' );
309 }
310
311 if ( ( count( $goals ) > 8 ) ) {
312 throw new \InvalidArgumentException( 'invalid value for $goals when calling GoalCreateRequestBulkGetOrCreate., number of items must be less than or equal to 8.' );
313 }
314 if ( ( count( $goals ) < 1 ) ) {
315 throw new \InvalidArgumentException( 'invalid length for $goals when calling GoalCreateRequestBulkGetOrCreate., number of items must be greater than or equal to 1.' );
316 }
317 $this->container['goals'] = $goals;
318
319 return $this;
320 }
321
322 /**
323 * Returns true if offset exists. False otherwise.
324 *
325 * @param integer $offset Offset
326 *
327 * @return boolean
328 */
329 public function offsetExists( $offset ): bool {
330 return isset( $this->container[ $offset ] );
331 }
332
333 /**
334 * Gets offset.
335 *
336 * @param integer $offset Offset
337 *
338 * @return mixed|null
339 */
340 #[\ReturnTypeWillChange]
341 public function offsetGet( $offset ) {
342 return $this->container[ $offset ] ?? null;
343 }
344
345 /**
346 * Sets value based on offset.
347 *
348 * @param int|null $offset Offset
349 * @param mixed $value Value to be set
350 *
351 * @return void
352 */
353 public function offsetSet( $offset, $value ): void {
354 if ( is_null( $offset ) ) {
355 $this->container[] = $value;
356 } else {
357 $this->container[ $offset ] = $value;
358 }
359 }
360
361 /**
362 * Unsets offset.
363 *
364 * @param integer $offset Offset
365 *
366 * @return void
367 */
368 public function offsetUnset( $offset ): void {
369 unset( $this->container[ $offset ] );
370 }
371
372 /**
373 * Serializes the object to a value that can be serialized natively by json_encode().
374 * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
375 *
376 * @return mixed Returns data which can be serialized by json_encode(), which is a value
377 * of any type other than a resource.
378 */
379 #[\ReturnTypeWillChange]
380 public function jsonSerialize() {
381 return ObjectSerializer::sanitizeForSerialization($this );
382 }
383
384 /**
385 * Gets the string presentation of the object
386 *
387 * @return string
388 */
389 public function __toString() {
390 return json_encode(
391 ObjectSerializer::sanitizeForSerialization( $this ),
392 JSON_PRETTY_PRINT
393 );
394 }
395
396 /**
397 * Gets a header-safe presentation of the object
398 *
399 * @return string
400 */
401 public function toHeaderValue() {
402 return json_encode( ObjectSerializer::sanitizeForSerialization($this));
403 }
404 }
405
406
407