PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13.1
1.8.13.1 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 All 212 releases
charitable / vendor / square / square / src / Legacy / Models / Device.php

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

163 lines 3.5 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 class Device implements \JsonSerializable
10 {
11 /**
12 * @var string|null
13 */
14 private $id;
15
16 /**
17 * @var DeviceAttributes
18 */
19 private $attributes;
20
21 /**
22 * @var array
23 */
24 private $components = [];
25
26 /**
27 * @var DeviceStatus|null
28 */
29 private $status;
30
31 /**
32 * @param DeviceAttributes $attributes
33 */
34 public function __construct(DeviceAttributes $attributes)
35 {
36 $this->attributes = $attributes;
37 }
38
39 /**
40 * Returns Id.
41 * A synthetic identifier for the device. The identifier includes a standardized prefix and
42 * is otherwise an opaque id generated from key device fields.
43 */
44 public function getId(): ?string
45 {
46 return $this->id;
47 }
48
49 /**
50 * Sets Id.
51 * A synthetic identifier for the device. The identifier includes a standardized prefix and
52 * is otherwise an opaque id generated from key device fields.
53 *
54 * @maps id
55 */
56 public function setId(?string $id): void
57 {
58 $this->id = $id;
59 }
60
61 /**
62 * Returns Attributes.
63 */
64 public function getAttributes(): DeviceAttributes
65 {
66 return $this->attributes;
67 }
68
69 /**
70 * Sets Attributes.
71 *
72 * @required
73 * @maps attributes
74 */
75 public function setAttributes(DeviceAttributes $attributes): void
76 {
77 $this->attributes = $attributes;
78 }
79
80 /**
81 * Returns Components.
82 * A list of components applicable to the device.
83 *
84 * @return Component[]|null
85 */
86 public function getComponents(): ?array
87 {
88 if (count($this->components) == 0) {
89 return null;
90 }
91 return $this->components['value'];
92 }
93
94 /**
95 * Sets Components.
96 * A list of components applicable to the device.
97 *
98 * @maps components
99 *
100 * @param Component[]|null $components
101 */
102 public function setComponents(?array $components): void
103 {
104 $this->components['value'] = $components;
105 }
106
107 /**
108 * Unsets Components.
109 * A list of components applicable to the device.
110 */
111 public function unsetComponents(): void
112 {
113 $this->components = [];
114 }
115
116 /**
117 * Returns Status.
118 */
119 public function getStatus(): ?DeviceStatus
120 {
121 return $this->status;
122 }
123
124 /**
125 * Sets Status.
126 *
127 * @maps status
128 */
129 public function setStatus(?DeviceStatus $status): void
130 {
131 $this->status = $status;
132 }
133
134 /**
135 * Encode this object to JSON
136 *
137 * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
138 * are set. (default: false)
139 *
140 * @return array|stdClass
141 */
142 #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
143 public function jsonSerialize(bool $asArrayWhenEmpty = false)
144 {
145 $json = [];
146 if (isset($this->id)) {
147 $json['id'] = $this->id;
148 }
149 $json['attributes'] = $this->attributes;
150 if (!empty($this->components)) {
151 $json['components'] = $this->components['value'];
152 }
153 if (isset($this->status)) {
154 $json['status'] = $this->status;
155 }
156 $json = array_filter($json, function ($val) {
157 return $val !== null;
158 });
159
160 return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
161 }
162 }
163