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

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

458 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * GoalCreateRequestPageview
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 * GoalCreateRequestPageview Class Doc Comment
36 *
37 * @category Class
38 * @description Pageview 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 GoalCreateRequestPageview 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.Pageview';
53
54 /**
55 * Array of property to type mappings. Used for (de)serialization
56 *
57 * @var string[]
58 */
59 protected static $openAPITypes = [
60 'goal' => '\Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageviewGoal',
61 'goal_type' => 'string'
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' => null,
73 'goal_type' => 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' => false,
83 'goal_type' => 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' => 'goal',
168 'goal_type' => 'goal_type'
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' => 'setGoal',
178 'goal_type' => 'setGoalType'
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' => 'getGoal',
188 'goal_type' => 'getGoalType'
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 public const GOAL_TYPE_GOAL_PAGEVIEW = 'Goal.Pageview';
229
230 /**
231 * Gets allowable values of the enum
232 *
233 * @return string[]
234 */
235 public function getGoalTypeAllowableValues() {
236 return [
237 self::GOAL_TYPE_GOAL_PAGEVIEW,
238 ];
239 }
240
241 /**
242 * Associative array for storing property values
243 *
244 * @var mixed[]
245 */
246 protected $container = [];
247
248 /**
249 * Constructor
250 *
251 * @param mixed[]|null $data Associated array of property values
252 * initializing the model
253 */
254 public function __construct( ?array $data = null ) {
255 $this->setIfExists( 'goal', $data ?? [], null );
256 $this->setIfExists( 'goal_type', $data ?? [], 'Goal.Pageview' );
257 }
258
259 /**
260 * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
261 * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
262 * $this->openAPINullablesSetToNull array
263 *
264 * @param string $variableName
265 * @param array $fields
266 * @param mixed $defaultValue
267 */
268 private function setIfExists( string $variableName, array $fields, $defaultValue ): void {
269 if ( self::isNullable( $variableName ) && array_key_exists( $variableName, $fields ) && is_null( $fields[ $variableName ] ) ) {
270 $this->openAPINullablesSetToNull[] = $variableName;
271 }
272
273 $this->container[ $variableName ] = $fields[ $variableName ] ?? $defaultValue;
274 }
275
276 /**
277 * Show all the invalid properties with reasons.
278 *
279 * @return array invalid properties with reasons
280 */
281 public function listInvalidProperties() {
282 $invalidProperties = [];
283
284 if ( $this->container['goal'] === null ) {
285 $invalidProperties[] = "'goal' can't be null";
286 }
287 if ( $this->container['goal_type'] === null ) {
288 $invalidProperties[] = "'goal_type' can't be null";
289 }
290 $allowedValues = $this->getGoalTypeAllowableValues();
291 if ( ! is_null( $this->container['goal_type'] ) && ! in_array( $this->container['goal_type'], $allowedValues, true ) ) {
292 $invalidProperties[] = sprintf(
293 "invalid value '%s' for 'goal_type', must be one of '%s'",
294 $this->container['goal_type'],
295 implode( "', '", $allowedValues )
296 );
297 }
298
299 return $invalidProperties;
300 }
301
302 /**
303 * Validate all the properties in the model
304 * return true if all passed
305 *
306 * @return bool True if all properties are valid
307 */
308 public function valid() {
309 return count( $this->listInvalidProperties()) === 0;
310 }
311
312
313 /**
314 * Gets goal
315 *
316 * @return \Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageviewGoal
317 */
318 public function getGoal() {
319 return $this->container['goal'];
320 }
321
322 /**
323 * Sets goal
324 *
325 * @param \Plausible\Analytics\WP\Client\Model\GoalCreateRequestPageviewGoal $goal goal
326 *
327 * @return self
328 */
329 public function setGoal( $goal ) {
330 if ( is_null( $goal ) ) {
331 throw new \InvalidArgumentException( 'non-nullable goal cannot be null' );
332 }
333 $this->container['goal'] = $goal;
334
335 return $this;
336 }
337
338 /**
339 * Gets goal_type
340 *
341 * @return string
342 */
343 public function getGoalType() {
344 return $this->container['goal_type'];
345 }
346
347 /**
348 * Sets goal_type
349 *
350 * @param string $goal_type goal_type
351 *
352 * @return self
353 */
354 public function setGoalType( $goal_type ) {
355 if ( is_null( $goal_type ) ) {
356 throw new \InvalidArgumentException( 'non-nullable goal_type cannot be null' );
357 }
358 $allowedValues = $this->getGoalTypeAllowableValues();
359 if ( ! in_array( $goal_type, $allowedValues, true ) ) {
360 throw new \InvalidArgumentException(
361 sprintf(
362 "Invalid value '%s' for 'goal_type', must be one of '%s'",
363 $goal_type,
364 implode( "', '", $allowedValues )
365 )
366 );
367 }
368 $this->container['goal_type'] = $goal_type;
369
370 return $this;
371 }
372
373 /**
374 * Returns true if offset exists. False otherwise.
375 *
376 * @param integer $offset Offset
377 *
378 * @return boolean
379 */
380 public function offsetExists( $offset ): bool {
381 return isset( $this->container[ $offset ] );
382 }
383
384 /**
385 * Gets offset.
386 *
387 * @param integer $offset Offset
388 *
389 * @return mixed|null
390 */
391 #[\ReturnTypeWillChange]
392 public function offsetGet( $offset ) {
393 return $this->container[ $offset ] ?? null;
394 }
395
396 /**
397 * Sets value based on offset.
398 *
399 * @param int|null $offset Offset
400 * @param mixed $value Value to be set
401 *
402 * @return void
403 */
404 public function offsetSet( $offset, $value ): void {
405 if ( is_null( $offset ) ) {
406 $this->container[] = $value;
407 } else {
408 $this->container[ $offset ] = $value;
409 }
410 }
411
412 /**
413 * Unsets offset.
414 *
415 * @param integer $offset Offset
416 *
417 * @return void
418 */
419 public function offsetUnset( $offset ): void {
420 unset( $this->container[ $offset ] );
421 }
422
423 /**
424 * Serializes the object to a value that can be serialized natively by json_encode().
425 * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
426 *
427 * @return mixed Returns data which can be serialized by json_encode(), which is a value
428 * of any type other than a resource.
429 */
430 #[\ReturnTypeWillChange]
431 public function jsonSerialize() {
432 return ObjectSerializer::sanitizeForSerialization($this );
433 }
434
435 /**
436 * Gets the string presentation of the object
437 *
438 * @return string
439 */
440 public function __toString() {
441 return json_encode(
442 ObjectSerializer::sanitizeForSerialization( $this ),
443 JSON_PRETTY_PRINT
444 );
445 }
446
447 /**
448 * Gets a header-safe presentation of the object
449 *
450 * @return string
451 */
452 public function toHeaderValue() {
453 return json_encode( ObjectSerializer::sanitizeForSerialization($this));
454 }
455 }
456
457
458