commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
VariantImagesSetMessageModel.php
1<?php
2
3declare(strict_types=1);
10
24use DateTimeImmutable;
25use stdClass;
26
31{
32 public const DISCRIMINATOR_VALUE = 'VariantImagesSet';
37 protected $id;
38
43 protected $version;
44
49 protected $createdAt;
50
55 protected $lastModifiedAt;
56
61 protected $lastModifiedBy;
62
67 protected $createdBy;
68
73 protected $sequenceNumber;
74
79 protected $resource;
80
86
91 protected $type;
92
98
103 protected $product;
104
109 protected $images;
110
115 protected $oldImages;
116
121 protected $staged;
122
123
127 public function __construct(
128 ?string $id = null,
129 ?int $version = null,
130 ?DateTimeImmutable $createdAt = null,
131 ?DateTimeImmutable $lastModifiedAt = null,
133 ?CreatedBy $createdBy = null,
134 ?int $sequenceNumber = null,
135 ?Reference $resource = null,
136 ?int $resourceVersion = null,
139 ?ImageCollection $images = null,
141 ?bool $staged = null,
142 ?string $type = null
143 ) {
144 $this->id = $id;
145 $this->version = $version;
146 $this->createdAt = $createdAt;
147 $this->lastModifiedAt = $lastModifiedAt;
148 $this->lastModifiedBy = $lastModifiedBy;
149 $this->createdBy = $createdBy;
150 $this->sequenceNumber = $sequenceNumber;
151 $this->resource = $resource;
152 $this->resourceVersion = $resourceVersion;
153 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
154 $this->product = $product;
155 $this->images = $images;
156 $this->oldImages = $oldImages;
157 $this->staged = $staged;
158 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
159 }
160
167 public function getId()
168 {
169 if (is_null($this->id)) {
171 $data = $this->raw(self::FIELD_ID);
172 if (is_null($data)) {
173 return null;
174 }
175 $this->id = (string) $data;
176 }
177
178 return $this->id;
179 }
180
187 public function getVersion()
188 {
189 if (is_null($this->version)) {
191 $data = $this->raw(self::FIELD_VERSION);
192 if (is_null($data)) {
193 return null;
194 }
195 $this->version = (int) $data;
196 }
197
198 return $this->version;
199 }
200
207 public function getCreatedAt()
208 {
209 if (is_null($this->createdAt)) {
211 $data = $this->raw(self::FIELD_CREATED_AT);
212 if (is_null($data)) {
213 return null;
214 }
215 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
216 if (false === $data) {
217 return null;
218 }
219 $this->createdAt = $data;
220 }
221
222 return $this->createdAt;
223 }
224
231 public function getLastModifiedAt()
232 {
233 if (is_null($this->lastModifiedAt)) {
235 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
236 if (is_null($data)) {
237 return null;
238 }
239 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
240 if (false === $data) {
241 return null;
242 }
243 $this->lastModifiedAt = $data;
244 }
245
247 }
248
255 public function getLastModifiedBy()
256 {
257 if (is_null($this->lastModifiedBy)) {
259 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
260 if (is_null($data)) {
261 return null;
262 }
263
264 $this->lastModifiedBy = LastModifiedByModel::of($data);
265 }
266
268 }
269
276 public function getCreatedBy()
277 {
278 if (is_null($this->createdBy)) {
280 $data = $this->raw(self::FIELD_CREATED_BY);
281 if (is_null($data)) {
282 return null;
283 }
284
285 $this->createdBy = CreatedByModel::of($data);
286 }
287
288 return $this->createdBy;
289 }
290
298 public function getSequenceNumber()
299 {
300 if (is_null($this->sequenceNumber)) {
302 $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
303 if (is_null($data)) {
304 return null;
305 }
306 $this->sequenceNumber = (int) $data;
307 }
308
310 }
311
318 public function getResource()
319 {
320 if (is_null($this->resource)) {
322 $data = $this->raw(self::FIELD_RESOURCE);
323 if (is_null($data)) {
324 return null;
325 }
326 $className = ReferenceModel::resolveDiscriminatorClass($data);
327 $this->resource = $className::of($data);
328 }
329
330 return $this->resource;
331 }
332
339 public function getResourceVersion()
340 {
341 if (is_null($this->resourceVersion)) {
343 $data = $this->raw(self::FIELD_RESOURCE_VERSION);
344 if (is_null($data)) {
345 return null;
346 }
347 $this->resourceVersion = (int) $data;
348 }
349
351 }
352
359 public function getType()
360 {
361 if (is_null($this->type)) {
363 $data = $this->raw(self::FIELD_TYPE);
364 if (is_null($data)) {
365 return null;
366 }
367 $this->type = (string) $data;
368 }
369
370 return $this->type;
371 }
372
380 {
381 if (is_null($this->resourceUserProvidedIdentifiers)) {
383 $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
384 if (is_null($data)) {
385 return null;
386 }
387
388 $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
389 }
390
392 }
393
400 public function getProduct()
401 {
402 if (is_null($this->product)) {
404 $data = $this->raw(self::FIELD_PRODUCT);
405 if (is_null($data)) {
406 return null;
407 }
408
409 $this->product = ProductReferenceModel::of($data);
410 }
411
412 return $this->product;
413 }
414
421 public function getImages()
422 {
423 if (is_null($this->images)) {
425 $data = $this->raw(self::FIELD_IMAGES);
426 if (is_null($data)) {
427 return null;
428 }
429 $this->images = ImageCollection::fromArray($data);
430 }
431
432 return $this->images;
433 }
434
441 public function getOldImages()
442 {
443 if (is_null($this->oldImages)) {
445 $data = $this->raw(self::FIELD_OLD_IMAGES);
446 if (is_null($data)) {
447 return null;
448 }
449 $this->oldImages = ImageCollection::fromArray($data);
450 }
451
452 return $this->oldImages;
453 }
454
461 public function getStaged()
462 {
463 if (is_null($this->staged)) {
465 $data = $this->raw(self::FIELD_STAGED);
466 if (is_null($data)) {
467 return null;
468 }
469 $this->staged = (bool) $data;
470 }
471
472 return $this->staged;
473 }
474
475
479 public function setId(?string $id): void
480 {
481 $this->id = $id;
482 }
483
487 public function setVersion(?int $version): void
488 {
489 $this->version = $version;
490 }
491
495 public function setCreatedAt(?DateTimeImmutable $createdAt): void
496 {
497 $this->createdAt = $createdAt;
498 }
499
503 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
504 {
505 $this->lastModifiedAt = $lastModifiedAt;
506 }
507
512 {
513 $this->lastModifiedBy = $lastModifiedBy;
514 }
515
519 public function setCreatedBy(?CreatedBy $createdBy): void
520 {
521 $this->createdBy = $createdBy;
522 }
523
527 public function setSequenceNumber(?int $sequenceNumber): void
528 {
529 $this->sequenceNumber = $sequenceNumber;
530 }
531
535 public function setResource(?Reference $resource): void
536 {
537 $this->resource = $resource;
538 }
539
543 public function setResourceVersion(?int $resourceVersion): void
544 {
545 $this->resourceVersion = $resourceVersion;
546 }
547
552 {
553 $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
554 }
555
559 public function setProduct(?ProductReference $product): void
560 {
561 $this->product = $product;
562 }
563
567 public function setImages(?ImageCollection $images): void
568 {
569 $this->images = $images;
570 }
571
576 {
577 $this->oldImages = $oldImages;
578 }
579
583 public function setStaged(?bool $staged): void
584 {
585 $this->staged = $staged;
586 }
587
588
589 #[\ReturnTypeWillChange]
590 public function jsonSerialize()
591 {
592 $data = $this->toArray();
593 if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
594 $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
595 }
596
597 if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
598 $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
599 }
600 return (object) $data;
601 }
602}
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?int $sequenceNumber=null, ?Reference $resource=null, ?int $resourceVersion=null, ?UserProvidedIdentifiers $resourceUserProvidedIdentifiers=null, ?ProductReference $product=null, ?ImageCollection $images=null, ?ImageCollection $oldImages=null, ?bool $staged=null, ?string $type=null)