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

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

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