commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
All Classes Namespaces Functions Variables Pages
ProductTailoringModel.php
1<?php
2
3declare(strict_types=1);
10
26use DateTimeImmutable;
27use stdClass;
28
33{
38 protected $id;
39
44 protected $version;
45
50 protected $createdAt;
51
56 protected $lastModifiedAt;
57
62 protected $lastModifiedBy;
63
68 protected $createdBy;
69
74 protected $key;
75
80 protected $store;
81
86 protected $product;
87
92 protected $published;
93
98 protected $current;
99
104 protected $staged;
105
111
116 protected $warnings;
117
118
122 public function __construct(
123 ?string $id = null,
124 ?int $version = null,
125 ?DateTimeImmutable $createdAt = null,
126 ?DateTimeImmutable $lastModifiedAt = null,
128 ?CreatedBy $createdBy = null,
129 ?string $key = null,
132 ?bool $published = null,
135 ?bool $hasStagedChanges = null,
137 ) {
138 $this->id = $id;
139 $this->version = $version;
140 $this->createdAt = $createdAt;
141 $this->lastModifiedAt = $lastModifiedAt;
142 $this->lastModifiedBy = $lastModifiedBy;
143 $this->createdBy = $createdBy;
144 $this->key = $key;
145 $this->store = $store;
146 $this->product = $product;
147 $this->published = $published;
148 $this->current = $current;
149 $this->staged = $staged;
150 $this->hasStagedChanges = $hasStagedChanges;
151 $this->warnings = $warnings;
152 }
153
160 public function getId()
161 {
162 if (is_null($this->id)) {
164 $data = $this->raw(self::FIELD_ID);
165 if (is_null($data)) {
166 return null;
167 }
168 $this->id = (string) $data;
169 }
170
171 return $this->id;
172 }
173
180 public function getVersion()
181 {
182 if (is_null($this->version)) {
184 $data = $this->raw(self::FIELD_VERSION);
185 if (is_null($data)) {
186 return null;
187 }
188 $this->version = (int) $data;
189 }
190
191 return $this->version;
192 }
193
200 public function getCreatedAt()
201 {
202 if (is_null($this->createdAt)) {
204 $data = $this->raw(self::FIELD_CREATED_AT);
205 if (is_null($data)) {
206 return null;
207 }
208 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
209 if (false === $data) {
210 return null;
211 }
212 $this->createdAt = $data;
213 }
214
215 return $this->createdAt;
216 }
217
224 public function getLastModifiedAt()
225 {
226 if (is_null($this->lastModifiedAt)) {
228 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
229 if (is_null($data)) {
230 return null;
231 }
232 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
233 if (false === $data) {
234 return null;
235 }
236 $this->lastModifiedAt = $data;
237 }
238
240 }
241
248 public function getLastModifiedBy()
249 {
250 if (is_null($this->lastModifiedBy)) {
252 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
253 if (is_null($data)) {
254 return null;
255 }
256
257 $this->lastModifiedBy = LastModifiedByModel::of($data);
258 }
259
261 }
262
269 public function getCreatedBy()
270 {
271 if (is_null($this->createdBy)) {
273 $data = $this->raw(self::FIELD_CREATED_BY);
274 if (is_null($data)) {
275 return null;
276 }
277
278 $this->createdBy = CreatedByModel::of($data);
279 }
280
281 return $this->createdBy;
282 }
283
290 public function getKey()
291 {
292 if (is_null($this->key)) {
294 $data = $this->raw(self::FIELD_KEY);
295 if (is_null($data)) {
296 return null;
297 }
298 $this->key = (string) $data;
299 }
300
301 return $this->key;
302 }
303
310 public function getStore()
311 {
312 if (is_null($this->store)) {
314 $data = $this->raw(self::FIELD_STORE);
315 if (is_null($data)) {
316 return null;
317 }
318
319 $this->store = StoreKeyReferenceModel::of($data);
320 }
321
322 return $this->store;
323 }
324
331 public function getProduct()
332 {
333 if (is_null($this->product)) {
335 $data = $this->raw(self::FIELD_PRODUCT);
336 if (is_null($data)) {
337 return null;
338 }
339
340 $this->product = ProductReferenceModel::of($data);
341 }
342
343 return $this->product;
344 }
345
354 public function getPublished()
355 {
356 if (is_null($this->published)) {
358 $data = $this->raw(self::FIELD_PUBLISHED);
359 if (is_null($data)) {
360 return null;
361 }
362 $this->published = (bool) $data;
363 }
364
365 return $this->published;
366 }
367
374 public function getCurrent()
375 {
376 if (is_null($this->current)) {
378 $data = $this->raw(self::FIELD_CURRENT);
379 if (is_null($data)) {
380 return null;
381 }
382
383 $this->current = ProductTailoringDataModel::of($data);
384 }
385
386 return $this->current;
387 }
388
395 public function getStaged()
396 {
397 if (is_null($this->staged)) {
399 $data = $this->raw(self::FIELD_STAGED);
400 if (is_null($data)) {
401 return null;
402 }
403
404 $this->staged = ProductTailoringDataModel::of($data);
405 }
406
407 return $this->staged;
408 }
409
416 public function getHasStagedChanges()
417 {
418 if (is_null($this->hasStagedChanges)) {
420 $data = $this->raw(self::FIELD_HAS_STAGED_CHANGES);
421 if (is_null($data)) {
422 return null;
423 }
424 $this->hasStagedChanges = (bool) $data;
425 }
426
428 }
429
437 public function getWarnings()
438 {
439 if (is_null($this->warnings)) {
441 $data = $this->raw(self::FIELD_WARNINGS);
442 if (is_null($data)) {
443 return null;
444 }
445 $this->warnings = WarningObjectCollection::fromArray($data);
446 }
447
448 return $this->warnings;
449 }
450
451
455 public function setId(?string $id): void
456 {
457 $this->id = $id;
458 }
459
463 public function setVersion(?int $version): void
464 {
465 $this->version = $version;
466 }
467
471 public function setCreatedAt(?DateTimeImmutable $createdAt): void
472 {
473 $this->createdAt = $createdAt;
474 }
475
479 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
480 {
481 $this->lastModifiedAt = $lastModifiedAt;
482 }
483
488 {
489 $this->lastModifiedBy = $lastModifiedBy;
490 }
491
495 public function setCreatedBy(?CreatedBy $createdBy): void
496 {
497 $this->createdBy = $createdBy;
498 }
499
503 public function setKey(?string $key): void
504 {
505 $this->key = $key;
506 }
507
511 public function setStore(?StoreKeyReference $store): void
512 {
513 $this->store = $store;
514 }
515
519 public function setProduct(?ProductReference $product): void
520 {
521 $this->product = $product;
522 }
523
527 public function setPublished(?bool $published): void
528 {
529 $this->published = $published;
530 }
531
536 {
537 $this->current = $current;
538 }
539
543 public function setStaged(?ProductTailoringData $staged): void
544 {
545 $this->staged = $staged;
546 }
547
551 public function setHasStagedChanges(?bool $hasStagedChanges): void
552 {
553 $this->hasStagedChanges = $hasStagedChanges;
554 }
555
560 {
561 $this->warnings = $warnings;
562 }
563
564
565 #[\ReturnTypeWillChange]
566 public function jsonSerialize()
567 {
568 $data = $this->toArray();
569 if (isset($data[ProductTailoring::FIELD_CREATED_AT]) && $data[ProductTailoring::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
570 $data[ProductTailoring::FIELD_CREATED_AT] = $data[ProductTailoring::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
571 }
572
573 if (isset($data[ProductTailoring::FIELD_LAST_MODIFIED_AT]) && $data[ProductTailoring::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
574 $data[ProductTailoring::FIELD_LAST_MODIFIED_AT] = $data[ProductTailoring::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
575 }
576 return (object) $data;
577 }
578}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?StoreKeyReference $store=null, ?ProductReference $product=null, ?bool $published=null, ?ProductTailoringData $current=null, ?ProductTailoringData $staged=null, ?bool $hasStagedChanges=null, ?WarningObjectCollection $warnings=null)