commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
DiscountGroupModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
29final class DiscountGroupModel extends JsonObjectModel implements DiscountGroup
30{
35 protected $id;
36
41 protected $version;
42
47 protected $createdAt;
48
53 protected $lastModifiedAt;
54
59 protected $name;
60
65 protected $key;
66
71 protected $description;
72
77 protected $sortOrder;
78
83 protected $isActive;
84
89 protected $lastModifiedBy;
90
95 protected $createdBy;
96
97
101 public function __construct(
102 ?string $id = null,
103 ?int $version = null,
104 ?DateTimeImmutable $createdAt = null,
105 ?DateTimeImmutable $lastModifiedAt = null,
106 ?LocalizedString $name = null,
107 ?string $key = null,
109 ?string $sortOrder = null,
110 ?bool $isActive = null,
112 ?CreatedBy $createdBy = null
113 ) {
114 $this->id = $id;
115 $this->version = $version;
116 $this->createdAt = $createdAt;
117 $this->lastModifiedAt = $lastModifiedAt;
118 $this->name = $name;
119 $this->key = $key;
120 $this->description = $description;
121 $this->sortOrder = $sortOrder;
122 $this->isActive = $isActive;
123 $this->lastModifiedBy = $lastModifiedBy;
124 $this->createdBy = $createdBy;
125 }
126
133 public function getId()
134 {
135 if (is_null($this->id)) {
137 $data = $this->raw(self::FIELD_ID);
138 if (is_null($data)) {
139 return null;
140 }
141 $this->id = (string) $data;
142 }
143
144 return $this->id;
145 }
146
153 public function getVersion()
154 {
155 if (is_null($this->version)) {
157 $data = $this->raw(self::FIELD_VERSION);
158 if (is_null($data)) {
159 return null;
160 }
161 $this->version = (int) $data;
162 }
163
164 return $this->version;
165 }
166
173 public function getCreatedAt()
174 {
175 if (is_null($this->createdAt)) {
177 $data = $this->raw(self::FIELD_CREATED_AT);
178 if (is_null($data)) {
179 return null;
180 }
181 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
182 if (false === $data) {
183 return null;
184 }
185 $this->createdAt = $data;
186 }
187
188 return $this->createdAt;
189 }
190
197 public function getLastModifiedAt()
198 {
199 if (is_null($this->lastModifiedAt)) {
201 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
202 if (is_null($data)) {
203 return null;
204 }
205 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
206 if (false === $data) {
207 return null;
208 }
209 $this->lastModifiedAt = $data;
210 }
211
213 }
214
221 public function getName()
222 {
223 if (is_null($this->name)) {
225 $data = $this->raw(self::FIELD_NAME);
226 if (is_null($data)) {
227 return null;
228 }
229
230 $this->name = LocalizedStringModel::of($data);
231 }
232
233 return $this->name;
234 }
235
242 public function getKey()
243 {
244 if (is_null($this->key)) {
246 $data = $this->raw(self::FIELD_KEY);
247 if (is_null($data)) {
248 return null;
249 }
250 $this->key = (string) $data;
251 }
252
253 return $this->key;
254 }
255
262 public function getDescription()
263 {
264 if (is_null($this->description)) {
266 $data = $this->raw(self::FIELD_DESCRIPTION);
267 if (is_null($data)) {
268 return null;
269 }
270
271 $this->description = LocalizedStringModel::of($data);
272 }
273
274 return $this->description;
275 }
276
284 public function getSortOrder()
285 {
286 if (is_null($this->sortOrder)) {
288 $data = $this->raw(self::FIELD_SORT_ORDER);
289 if (is_null($data)) {
290 return null;
291 }
292 $this->sortOrder = (string) $data;
293 }
294
295 return $this->sortOrder;
296 }
297
304 public function getIsActive()
305 {
306 if (is_null($this->isActive)) {
308 $data = $this->raw(self::FIELD_IS_ACTIVE);
309 if (is_null($data)) {
310 return null;
311 }
312 $this->isActive = (bool) $data;
313 }
314
315 return $this->isActive;
316 }
317
324 public function getLastModifiedBy()
325 {
326 if (is_null($this->lastModifiedBy)) {
328 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
329 if (is_null($data)) {
330 return null;
331 }
332
333 $this->lastModifiedBy = LastModifiedByModel::of($data);
334 }
335
337 }
338
345 public function getCreatedBy()
346 {
347 if (is_null($this->createdBy)) {
349 $data = $this->raw(self::FIELD_CREATED_BY);
350 if (is_null($data)) {
351 return null;
352 }
353
354 $this->createdBy = CreatedByModel::of($data);
355 }
356
357 return $this->createdBy;
358 }
359
360
364 public function setId(?string $id): void
365 {
366 $this->id = $id;
367 }
368
372 public function setVersion(?int $version): void
373 {
374 $this->version = $version;
375 }
376
380 public function setCreatedAt(?DateTimeImmutable $createdAt): void
381 {
382 $this->createdAt = $createdAt;
383 }
384
388 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
389 {
390 $this->lastModifiedAt = $lastModifiedAt;
391 }
392
396 public function setName(?LocalizedString $name): void
397 {
398 $this->name = $name;
399 }
400
404 public function setKey(?string $key): void
405 {
406 $this->key = $key;
407 }
408
413 {
414 $this->description = $description;
415 }
416
420 public function setSortOrder(?string $sortOrder): void
421 {
422 $this->sortOrder = $sortOrder;
423 }
424
428 public function setIsActive(?bool $isActive): void
429 {
430 $this->isActive = $isActive;
431 }
432
437 {
438 $this->lastModifiedBy = $lastModifiedBy;
439 }
440
444 public function setCreatedBy(?CreatedBy $createdBy): void
445 {
446 $this->createdBy = $createdBy;
447 }
448
449
450 #[\ReturnTypeWillChange]
451 public function jsonSerialize()
452 {
453 $data = $this->toArray();
454 if (isset($data[DiscountGroup::FIELD_CREATED_AT]) && $data[DiscountGroup::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
455 $data[DiscountGroup::FIELD_CREATED_AT] = $data[DiscountGroup::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
456 }
457
458 if (isset($data[DiscountGroup::FIELD_LAST_MODIFIED_AT]) && $data[DiscountGroup::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
459 $data[DiscountGroup::FIELD_LAST_MODIFIED_AT] = $data[DiscountGroup::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
460 }
461 return (object) $data;
462 }
463}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LocalizedString $name=null, ?string $key=null, ?LocalizedString $description=null, ?string $sortOrder=null, ?bool $isActive=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null)