commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
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
352 public function getPublished()
353 {
354 if (is_null($this->published)) {
356 $data = $this->raw(self::FIELD_PUBLISHED);
357 if (is_null($data)) {
358 return null;
359 }
360 $this->published = (bool) $data;
361 }
362
363 return $this->published;
364 }
365
372 public function getCurrent()
373 {
374 if (is_null($this->current)) {
376 $data = $this->raw(self::FIELD_CURRENT);
377 if (is_null($data)) {
378 return null;
379 }
380
381 $this->current = ProductTailoringDataModel::of($data);
382 }
383
384 return $this->current;
385 }
386
393 public function getStaged()
394 {
395 if (is_null($this->staged)) {
397 $data = $this->raw(self::FIELD_STAGED);
398 if (is_null($data)) {
399 return null;
400 }
401
402 $this->staged = ProductTailoringDataModel::of($data);
403 }
404
405 return $this->staged;
406 }
407
414 public function getHasStagedChanges()
415 {
416 if (is_null($this->hasStagedChanges)) {
418 $data = $this->raw(self::FIELD_HAS_STAGED_CHANGES);
419 if (is_null($data)) {
420 return null;
421 }
422 $this->hasStagedChanges = (bool) $data;
423 }
424
426 }
427
435 public function getWarnings()
436 {
437 if (is_null($this->warnings)) {
439 $data = $this->raw(self::FIELD_WARNINGS);
440 if (is_null($data)) {
441 return null;
442 }
443 $this->warnings = WarningObjectCollection::fromArray($data);
444 }
445
446 return $this->warnings;
447 }
448
449
453 public function setId(?string $id): void
454 {
455 $this->id = $id;
456 }
457
461 public function setVersion(?int $version): void
462 {
463 $this->version = $version;
464 }
465
469 public function setCreatedAt(?DateTimeImmutable $createdAt): void
470 {
471 $this->createdAt = $createdAt;
472 }
473
477 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
478 {
479 $this->lastModifiedAt = $lastModifiedAt;
480 }
481
486 {
487 $this->lastModifiedBy = $lastModifiedBy;
488 }
489
493 public function setCreatedBy(?CreatedBy $createdBy): void
494 {
495 $this->createdBy = $createdBy;
496 }
497
501 public function setKey(?string $key): void
502 {
503 $this->key = $key;
504 }
505
509 public function setStore(?StoreKeyReference $store): void
510 {
511 $this->store = $store;
512 }
513
517 public function setProduct(?ProductReference $product): void
518 {
519 $this->product = $product;
520 }
521
525 public function setPublished(?bool $published): void
526 {
527 $this->published = $published;
528 }
529
534 {
535 $this->current = $current;
536 }
537
541 public function setStaged(?ProductTailoringData $staged): void
542 {
543 $this->staged = $staged;
544 }
545
549 public function setHasStagedChanges(?bool $hasStagedChanges): void
550 {
551 $this->hasStagedChanges = $hasStagedChanges;
552 }
553
558 {
559 $this->warnings = $warnings;
560 }
561
562
563 #[\ReturnTypeWillChange]
564 public function jsonSerialize()
565 {
566 $data = $this->toArray();
567 if (isset($data[ProductTailoring::FIELD_CREATED_AT]) && $data[ProductTailoring::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
568 $data[ProductTailoring::FIELD_CREATED_AT] = $data[ProductTailoring::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
569 }
570
571 if (isset($data[ProductTailoring::FIELD_LAST_MODIFIED_AT]) && $data[ProductTailoring::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
572 $data[ProductTailoring::FIELD_LAST_MODIFIED_AT] = $data[ProductTailoring::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
573 }
574 return (object) $data;
575 }
576}
__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)