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

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

508 lines 11.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * GoalCreateRequest
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 * GoalCreateRequest Class Doc Comment
36 *
37 * @category Class
38 * @description Goal creation params
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 GoalCreateRequest 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';
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 'goal' => '\Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageviewGoal',
62 'goal_type' => 'string'
63 ];
64
65 /**
66 * Array of property to format mappings. Used for (de)serialization
67 *
68 * @var string[]
69 * @phpstan-var array<string, string|null>
70 * @psalm-var array<string, string|null>
71 */
72 protected static $openAPIFormats = [
73 'goals' => null,
74 'goal' => null,
75 'goal_type' => null
76 ];
77
78 /**
79 * Array of nullable properties. Used for (de)serialization
80 *
81 * @var boolean[]
82 */
83 protected static array $openAPINullables = [
84 'goals' => false,
85 'goal' => false,
86 'goal_type' => false
87 ];
88
89 /**
90 * If a nullable field gets set to null, insert it here
91 *
92 * @var boolean[]
93 */
94 protected array $openAPINullablesSetToNull = [];
95
96 /**
97 * Array of property to type mappings. Used for (de)serialization
98 *
99 * @return array
100 */
101 public static function openAPITypes() {
102 return self::$openAPITypes;
103 }
104
105 /**
106 * Array of property to format mappings. Used for (de)serialization
107 *
108 * @return array
109 */
110 public static function openAPIFormats() {
111 return self::$openAPIFormats;
112 }
113
114 /**
115 * Array of nullable properties
116 *
117 * @return array
118 */
119 protected static function openAPINullables(): array {
120 return self::$openAPINullables;
121 }
122
123 /**
124 * Array of nullable field names deliberately set to null
125 *
126 * @return boolean[]
127 */
128 private function getOpenAPINullablesSetToNull(): array {
129 return $this->openAPINullablesSetToNull;
130 }
131
132 /**
133 * Setter - Array of nullable field names deliberately set to null
134 *
135 * @param boolean[] $openAPINullablesSetToNull
136 */
137 private function setOpenAPINullablesSetToNull( array $openAPINullablesSetToNull ): void {
138 $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
139 }
140
141 /**
142 * Checks if a property is nullable
143 *
144 * @param string $property
145 *
146 * @return bool
147 */
148 public static function isNullable( string $property ): bool {
149 return self::openAPINullables()[ $property ] ?? false;
150 }
151
152 /**
153 * Checks if a nullable property is set to null.
154 *
155 * @param string $property
156 *
157 * @return bool
158 */
159 public function isNullableSetToNull( string $property ): bool {
160 return in_array( $property, $this->getOpenAPINullablesSetToNull(), true );
161 }
162
163 /**
164 * Array of attributes where the key is the local name,
165 * and the value is the original name
166 *
167 * @var string[]
168 */
169 protected static $attributeMap = [
170 'goals' => 'goals',
171 'goal' => 'goal',
172 'goal_type' => 'goal_type'
173 ];
174
175 /**
176 * Array of attributes to setter functions (for deserialization of responses)
177 *
178 * @var string[]
179 */
180 protected static $setters = [
181 'goals' => 'setGoals',
182 'goal' => 'setGoal',
183 'goal_type' => 'setGoalType'
184 ];
185
186 /**
187 * Array of attributes to getter functions (for serialization of requests)
188 *
189 * @var string[]
190 */
191 protected static $getters = [
192 'goals' => 'getGoals',
193 'goal' => 'getGoal',
194 'goal_type' => 'getGoalType'
195 ];
196
197 /**
198 * Array of attributes where the key is the local name,
199 * and the value is the original name
200 *
201 * @return array
202 */
203 public static function attributeMap() {
204 return self::$attributeMap;
205 }
206
207 /**
208 * Array of attributes to setter functions (for deserialization of responses)
209 *
210 * @return array
211 */
212 public static function setters() {
213 return self::$setters;
214 }
215
216 /**
217 * Array of attributes to getter functions (for serialization of requests)
218 *
219 * @return array
220 */
221 public static function getters() {
222 return self::$getters;
223 }
224
225 /**
226 * The original name of the model.
227 *
228 * @return string
229 */
230 public function getModelName() {
231 return self::$openAPIModelName;
232 }
233
234 public const GOAL_TYPE_GOAL_PAGEVIEW = 'Goal.Pageview';
235
236 /**
237 * Gets allowable values of the enum
238 *
239 * @return string[]
240 */
241 public function getGoalTypeAllowableValues() {
242 return [
243 self::GOAL_TYPE_GOAL_PAGEVIEW,
244 ];
245 }
246
247 /**
248 * Associative array for storing property values
249 *
250 * @var mixed[]
251 */
252 protected $container = [];
253
254 /**
255 * Constructor
256 *
257 * @param mixed[]|null $data Associated array of property values
258 * initializing the model
259 */
260 public function __construct( ?array $data = null ) {
261 $this->setIfExists( 'goals', $data ?? [], null );
262 $this->setIfExists( 'goal', $data ?? [], null );
263 $this->setIfExists( 'goal_type', $data ?? [], 'Goal.Pageview' );
264 }
265
266 /**
267 * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
268 * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
269 * $this->openAPINullablesSetToNull array
270 *
271 * @param string $variableName
272 * @param array $fields
273 * @param mixed $defaultValue
274 */
275 private function setIfExists( string $variableName, array $fields, $defaultValue ): void {
276 if ( self::isNullable( $variableName ) && array_key_exists( $variableName, $fields ) && is_null( $fields[ $variableName ] ) ) {
277 $this->openAPINullablesSetToNull[] = $variableName;
278 }
279
280 $this->container[ $variableName ] = $fields[ $variableName ] ?? $defaultValue;
281 }
282
283 /**
284 * Show all the invalid properties with reasons.
285 *
286 * @return array invalid properties with reasons
287 */
288 public function listInvalidProperties() {
289 $invalidProperties = [];
290
291 if ( $this->container['goals'] === null ) {
292 $invalidProperties[] = "'goals' can't be null";
293 }
294 if ( ( count( $this->container['goals'] ) > 8 ) ) {
295 $invalidProperties[] = "invalid value for 'goals', number of items must be less than or equal to 8.";
296 }
297
298 if ( ( count( $this->container['goals'] ) < 1 ) ) {
299 $invalidProperties[] = "invalid value for 'goals', number of items must be greater than or equal to 1.";
300 }
301
302 if ( $this->container['goal'] === null ) {
303 $invalidProperties[] = "'goal' can't be null";
304 }
305 if ( $this->container['goal_type'] === null ) {
306 $invalidProperties[] = "'goal_type' can't be null";
307 }
308 $allowedValues = $this->getGoalTypeAllowableValues();
309 if ( ! is_null( $this->container['goal_type'] ) && ! in_array( $this->container['goal_type'], $allowedValues, true ) ) {
310 $invalidProperties[] = sprintf(
311 "invalid value '%s' for 'goal_type', must be one of '%s'",
312 $this->container['goal_type'],
313 implode( "', '", $allowedValues )
314 );
315 }
316
317 return $invalidProperties;
318 }
319
320 /**
321 * Validate all the properties in the model
322 * return true if all passed
323 *
324 * @return bool True if all properties are valid
325 */
326 public function valid() {
327 return count( $this->listInvalidProperties()) === 0;
328 }
329
330
331 /**
332 * Gets goals
333 *
334 * @return \Plausible\Analytics\WP\Client\Model\GoalCreateRequestBulkGetOrCreateGoalsInner[]
335 */
336 public function getGoals() {
337 return $this->container['goals'];
338 }
339
340 /**
341 * Sets goals
342 *
343 * @param \Plausible\Analytics\WP\Client\Model\GoalCreateRequestBulkGetOrCreateGoalsInner[] $goals goals
344 *
345 * @return self
346 */
347 public function setGoals( $goals ) {
348 if ( is_null( $goals ) ) {
349 throw new \InvalidArgumentException( 'non-nullable goals cannot be null' );
350 }
351
352 if ( ( count( $goals ) > 8 ) ) {
353 throw new \InvalidArgumentException( 'invalid value for $goals when calling GoalCreateRequest., number of items must be less than or equal to 8.' );
354 }
355 if ( ( count( $goals ) < 1 ) ) {
356 throw new \InvalidArgumentException( 'invalid length for $goals when calling GoalCreateRequest., number of items must be greater than or equal to 1.' );
357 }
358 $this->container['goals'] = $goals;
359
360 return $this;
361 }
362
363 /**
364 * Gets goal
365 *
366 * @return \Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageviewGoal
367 */
368 public function getGoal() {
369 return $this->container['goal'];
370 }
371
372 /**
373 * Sets goal
374 *
375 * @param \Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageviewGoal $goal goal
376 *
377 * @return self
378 */
379 public function setGoal( $goal ) {
380 if ( is_null( $goal ) ) {
381 throw new \InvalidArgumentException( 'non-nullable goal cannot be null' );
382 }
383 $this->container['goal'] = $goal;
384
385 return $this;
386 }
387
388 /**
389 * Gets goal_type
390 *
391 * @return string
392 */
393 public function getGoalType() {
394 return $this->container['goal_type'];
395 }
396
397 /**
398 * Sets goal_type
399 *
400 * @param string $goal_type goal_type
401 *
402 * @return self
403 */
404 public function setGoalType( $goal_type ) {
405 if ( is_null( $goal_type ) ) {
406 throw new \InvalidArgumentException( 'non-nullable goal_type cannot be null' );
407 }
408 $allowedValues = $this->getGoalTypeAllowableValues();
409 if ( ! in_array( $goal_type, $allowedValues, true ) ) {
410 throw new \InvalidArgumentException(
411 sprintf(
412 "Invalid value '%s' for 'goal_type', must be one of '%s'",
413 $goal_type,
414 implode( "', '", $allowedValues )
415 )
416 );
417 }
418 $this->container['goal_type'] = $goal_type;
419
420 return $this;
421 }
422
423 /**
424 * Returns true if offset exists. False otherwise.
425 *
426 * @param integer $offset Offset
427 *
428 * @return boolean
429 */
430 public function offsetExists( $offset ): bool {
431 return isset( $this->container[ $offset ] );
432 }
433
434 /**
435 * Gets offset.
436 *
437 * @param integer $offset Offset
438 *
439 * @return mixed|null
440 */
441 #[\ReturnTypeWillChange]
442 public function offsetGet( $offset ) {
443 return $this->container[ $offset ] ?? null;
444 }
445
446 /**
447 * Sets value based on offset.
448 *
449 * @param int|null $offset Offset
450 * @param mixed $value Value to be set
451 *
452 * @return void
453 */
454 public function offsetSet( $offset, $value ): void {
455 if ( is_null( $offset ) ) {
456 $this->container[] = $value;
457 } else {
458 $this->container[ $offset ] = $value;
459 }
460 }
461
462 /**
463 * Unsets offset.
464 *
465 * @param integer $offset Offset
466 *
467 * @return void
468 */
469 public function offsetUnset( $offset ): void {
470 unset( $this->container[ $offset ] );
471 }
472
473 /**
474 * Serializes the object to a value that can be serialized natively by json_encode().
475 * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
476 *
477 * @return mixed Returns data which can be serialized by json_encode(), which is a value
478 * of any type other than a resource.
479 */
480 #[\ReturnTypeWillChange]
481 public function jsonSerialize() {
482 return ObjectSerializer::sanitizeForSerialization($this );
483 }
484
485 /**
486 * Gets the string presentation of the object
487 *
488 * @return string
489 */
490 public function __toString() {
491 return json_encode(
492 ObjectSerializer::sanitizeForSerialization( $this ),
493 JSON_PRETTY_PRINT
494 );
495 }
496
497 /**
498 * Gets a header-safe presentation of the object
499 *
500 * @return string
501 */
502 public function toHeaderValue() {
503 return json_encode( ObjectSerializer::sanitizeForSerialization($this));
504 }
505 }
506
507
508