commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
StoreModel.php
1<?php
2
3declare(strict_types=1);
10
27use DateTimeImmutable;
28use stdClass;
29
33final class StoreModel extends JsonObjectModel implements Store
34{
39 protected $id;
40
45 protected $version;
46
51 protected $createdAt;
52
57 protected $lastModifiedAt;
58
63 protected $lastModifiedBy;
64
69 protected $createdBy;
70
75 protected $key;
76
81 protected $name;
82
87 protected $languages;
88
93 protected $countries;
94
100
106
112
117 protected $custom;
118
123 protected $storefront;
124
125
129 public function __construct(
130 ?string $id = null,
131 ?int $version = null,
132 ?DateTimeImmutable $createdAt = null,
133 ?DateTimeImmutable $lastModifiedAt = null,
135 ?CreatedBy $createdBy = null,
136 ?string $key = null,
137 ?LocalizedString $name = null,
138 ?array $languages = null,
143 ?CustomFields $custom = null,
144 ?Storefront $storefront = null
145 ) {
146 $this->id = $id;
147 $this->version = $version;
148 $this->createdAt = $createdAt;
149 $this->lastModifiedAt = $lastModifiedAt;
150 $this->lastModifiedBy = $lastModifiedBy;
151 $this->createdBy = $createdBy;
152 $this->key = $key;
153 $this->name = $name;
154 $this->languages = $languages;
155 $this->countries = $countries;
156 $this->distributionChannels = $distributionChannels;
157 $this->supplyChannels = $supplyChannels;
158 $this->productSelections = $productSelections;
159 $this->custom = $custom;
160 $this->storefront = $storefront;
161 }
162
169 public function getId()
170 {
171 if (is_null($this->id)) {
173 $data = $this->raw(self::FIELD_ID);
174 if (is_null($data)) {
175 return null;
176 }
177 $this->id = (string) $data;
178 }
179
180 return $this->id;
181 }
182
189 public function getVersion()
190 {
191 if (is_null($this->version)) {
193 $data = $this->raw(self::FIELD_VERSION);
194 if (is_null($data)) {
195 return null;
196 }
197 $this->version = (int) $data;
198 }
199
200 return $this->version;
201 }
202
209 public function getCreatedAt()
210 {
211 if (is_null($this->createdAt)) {
213 $data = $this->raw(self::FIELD_CREATED_AT);
214 if (is_null($data)) {
215 return null;
216 }
217 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
218 if (false === $data) {
219 return null;
220 }
221 $this->createdAt = $data;
222 }
223
224 return $this->createdAt;
225 }
226
233 public function getLastModifiedAt()
234 {
235 if (is_null($this->lastModifiedAt)) {
237 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
238 if (is_null($data)) {
239 return null;
240 }
241 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
242 if (false === $data) {
243 return null;
244 }
245 $this->lastModifiedAt = $data;
246 }
247
249 }
250
257 public function getLastModifiedBy()
258 {
259 if (is_null($this->lastModifiedBy)) {
261 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
262 if (is_null($data)) {
263 return null;
264 }
265
266 $this->lastModifiedBy = LastModifiedByModel::of($data);
267 }
268
270 }
271
278 public function getCreatedBy()
279 {
280 if (is_null($this->createdBy)) {
282 $data = $this->raw(self::FIELD_CREATED_BY);
283 if (is_null($data)) {
284 return null;
285 }
286
287 $this->createdBy = CreatedByModel::of($data);
288 }
289
290 return $this->createdBy;
291 }
292
299 public function getKey()
300 {
301 if (is_null($this->key)) {
303 $data = $this->raw(self::FIELD_KEY);
304 if (is_null($data)) {
305 return null;
306 }
307 $this->key = (string) $data;
308 }
309
310 return $this->key;
311 }
312
319 public function getName()
320 {
321 if (is_null($this->name)) {
323 $data = $this->raw(self::FIELD_NAME);
324 if (is_null($data)) {
325 return null;
326 }
327
328 $this->name = LocalizedStringModel::of($data);
329 }
330
331 return $this->name;
332 }
333
340 public function getLanguages()
341 {
342 if (is_null($this->languages)) {
344 $data = $this->raw(self::FIELD_LANGUAGES);
345 if (is_null($data)) {
346 return null;
347 }
348 $this->languages = $data;
349 }
350
351 return $this->languages;
352 }
353
360 public function getCountries()
361 {
362 if (is_null($this->countries)) {
364 $data = $this->raw(self::FIELD_COUNTRIES);
365 if (is_null($data)) {
366 return null;
367 }
368 $this->countries = StoreCountryCollection::fromArray($data);
369 }
370
371 return $this->countries;
372 }
373
380 public function getDistributionChannels()
381 {
382 if (is_null($this->distributionChannels)) {
384 $data = $this->raw(self::FIELD_DISTRIBUTION_CHANNELS);
385 if (is_null($data)) {
386 return null;
387 }
388 $this->distributionChannels = ChannelReferenceCollection::fromArray($data);
389 }
390
392 }
393
400 public function getSupplyChannels()
401 {
402 if (is_null($this->supplyChannels)) {
404 $data = $this->raw(self::FIELD_SUPPLY_CHANNELS);
405 if (is_null($data)) {
406 return null;
407 }
408 $this->supplyChannels = ChannelReferenceCollection::fromArray($data);
409 }
410
412 }
413
426 public function getProductSelections()
427 {
428 if (is_null($this->productSelections)) {
430 $data = $this->raw(self::FIELD_PRODUCT_SELECTIONS);
431 if (is_null($data)) {
432 return null;
433 }
434 $this->productSelections = ProductSelectionSettingCollection::fromArray($data);
435 }
436
438 }
439
446 public function getCustom()
447 {
448 if (is_null($this->custom)) {
450 $data = $this->raw(self::FIELD_CUSTOM);
451 if (is_null($data)) {
452 return null;
453 }
454
455 $this->custom = CustomFieldsModel::of($data);
456 }
457
458 return $this->custom;
459 }
460
467 public function getStorefront()
468 {
469 if (is_null($this->storefront)) {
471 $data = $this->raw(self::FIELD_STOREFRONT);
472 if (is_null($data)) {
473 return null;
474 }
475
476 $this->storefront = StorefrontModel::of($data);
477 }
478
479 return $this->storefront;
480 }
481
482
486 public function setId(?string $id): void
487 {
488 $this->id = $id;
489 }
490
494 public function setVersion(?int $version): void
495 {
496 $this->version = $version;
497 }
498
502 public function setCreatedAt(?DateTimeImmutable $createdAt): void
503 {
504 $this->createdAt = $createdAt;
505 }
506
510 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
511 {
512 $this->lastModifiedAt = $lastModifiedAt;
513 }
514
519 {
520 $this->lastModifiedBy = $lastModifiedBy;
521 }
522
526 public function setCreatedBy(?CreatedBy $createdBy): void
527 {
528 $this->createdBy = $createdBy;
529 }
530
534 public function setKey(?string $key): void
535 {
536 $this->key = $key;
537 }
538
542 public function setName(?LocalizedString $name): void
543 {
544 $this->name = $name;
545 }
546
550 public function setLanguages(?array $languages): void
551 {
552 $this->languages = $languages;
553 }
554
559 {
560 $this->countries = $countries;
561 }
562
567 {
568 $this->distributionChannels = $distributionChannels;
569 }
570
575 {
576 $this->supplyChannels = $supplyChannels;
577 }
578
583 {
584 $this->productSelections = $productSelections;
585 }
586
590 public function setCustom(?CustomFields $custom): void
591 {
592 $this->custom = $custom;
593 }
594
598 public function setStorefront(?Storefront $storefront): void
599 {
600 $this->storefront = $storefront;
601 }
602
603
604 #[\ReturnTypeWillChange]
605 public function jsonSerialize()
606 {
607 $data = $this->toArray();
608 if (isset($data[Store::FIELD_CREATED_AT]) && $data[Store::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
609 $data[Store::FIELD_CREATED_AT] = $data[Store::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
610 }
611
612 if (isset($data[Store::FIELD_LAST_MODIFIED_AT]) && $data[Store::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
613 $data[Store::FIELD_LAST_MODIFIED_AT] = $data[Store::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
614 }
615 return (object) $data;
616 }
617}
setSupplyChannels(?ChannelReferenceCollection $supplyChannels)
setStorefront(?Storefront $storefront)
setCreatedAt(?DateTimeImmutable $createdAt)
setCountries(?StoreCountryCollection $countries)
setProductSelections(?ProductSelectionSettingCollection $productSelections)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setDistributionChannels(?ChannelReferenceCollection $distributionChannels)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?LocalizedString $name=null, ?array $languages=null, ?StoreCountryCollection $countries=null, ?ChannelReferenceCollection $distributionChannels=null, ?ChannelReferenceCollection $supplyChannels=null, ?ProductSelectionSettingCollection $productSelections=null, ?CustomFields $custom=null, ?Storefront $storefront=null)
static fromArray(array $data)