PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / vendor / square / square / src / Legacy / Models / CatalogModifierOverride.php

CatalogModifierOverride.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Models/CatalogModifierOverride.php

108 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Square\Legacy\Models;
6
7 use stdClass;
8
9 /**
10 * Options to control how to override the default behavior of the specified modifier.
11 */
12 class CatalogModifierOverride implements \JsonSerializable
13 {
14 /**
15 * @var string
16 */
17 private $modifierId;
18
19 /**
20 * @var array
21 */
22 private $onByDefault = [];
23
24 /**
25 * @param string $modifierId
26 */
27 public function __construct(string $modifierId)
28 {
29 $this->modifierId = $modifierId;
30 }
31
32 /**
33 * Returns Modifier Id.
34 * The ID of the `CatalogModifier` whose default behavior is being overridden.
35 */
36 public function getModifierId(): string
37 {
38 return $this->modifierId;
39 }
40
41 /**
42 * Sets Modifier Id.
43 * The ID of the `CatalogModifier` whose default behavior is being overridden.
44 *
45 * @required
46 * @maps modifier_id
47 */
48 public function setModifierId(string $modifierId): void
49 {
50 $this->modifierId = $modifierId;
51 }
52
53 /**
54 * Returns On by Default.
55 * If `true`, this `CatalogModifier` should be selected by default for this `CatalogItem`.
56 */
57 public function getOnByDefault(): ?bool
58 {
59 if (count($this->onByDefault) == 0) {
60 return null;
61 }
62 return $this->onByDefault['value'];
63 }
64
65 /**
66 * Sets On by Default.
67 * If `true`, this `CatalogModifier` should be selected by default for this `CatalogItem`.
68 *
69 * @maps on_by_default
70 */
71 public function setOnByDefault(?bool $onByDefault): void
72 {
73 $this->onByDefault['value'] = $onByDefault;
74 }
75
76 /**
77 * Unsets On by Default.
78 * If `true`, this `CatalogModifier` should be selected by default for this `CatalogItem`.
79 */
80 public function unsetOnByDefault(): void
81 {
82 $this->onByDefault = [];
83 }
84
85 /**
86 * Encode this object to JSON
87 *
88 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
89 * are set. (default: false)
90 *
91 * @return array|stdClass
92 */
93 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
94 public function jsonSerialize(bool $asArrayWhenEmpty = false)
95 {
96 $json = [];
97 $json['modifier_id'] = $this->modifierId;
98 if (!empty($this->onByDefault)) {
99 $json['on_by_default'] = $this->onByDefault['value'];
100 }
101 $json = array_filter($json, function ($val) {
102 return $val !== null;
103 });
104
105 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
106 }
107 }
108