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

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

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