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
119
123 public function __construct(
124 ?string $id = null,
125 ?int $version = null,
126 ?DateTimeImmutable $createdAt = null,
127 ?DateTimeImmutable $lastModifiedAt = null,
129 ?CreatedBy $createdBy = null,
130 ?string $key = null,
131 ?LocalizedString $name = null,
132 ?array $languages = null,
137 ?CustomFields $custom = null
138 ) {
139 $this->id = $id;
140 $this->version = $version;
141 $this->createdAt = $createdAt;
142 $this->lastModifiedAt = $lastModifiedAt;
143 $this->lastModifiedBy = $lastModifiedBy;
144 $this->createdBy = $createdBy;
145 $this->key = $key;
146 $this->name = $name;
147 $this->languages = $languages;
148 $this->countries = $countries;
149 $this->distributionChannels = $distributionChannels;
150 $this->supplyChannels = $supplyChannels;
151 $this->productSelections = $productSelections;
152 $this->custom = $custom;
153 }
154
161 public function getId()
162 {
163 if (is_null($this->id)) {
165 $data = $this->raw(self::FIELD_ID);
166 if (is_null($data)) {
167 return null;
168 }
169 $this->id = (string) $data;
170 }
171
172 return $this->id;
173 }
174
181 public function getVersion()
182 {
183 if (is_null($this->version)) {
185 $data = $this->raw(self::FIELD_VERSION);
186 if (is_null($data)) {
187 return null;
188 }
189 $this->version = (int) $data;
190 }
191
192 return $this->version;
193 }
194
201 public function getCreatedAt()
202 {
203 if (is_null($this->createdAt)) {
205 $data = $this->raw(self::FIELD_CREATED_AT);
206 if (is_null($data)) {
207 return null;
208 }
209 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
210 if (false === $data) {
211 return null;
212 }
213 $this->createdAt = $data;
214 }
215
216 return $this->createdAt;
217 }
218
225 public function getLastModifiedAt()
226 {
227 if (is_null($this->lastModifiedAt)) {
229 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
230 if (is_null($data)) {
231 return null;
232 }
233 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
234 if (false === $data) {
235 return null;
236 }
237 $this->lastModifiedAt = $data;
238 }
239
241 }
242
249 public function getLastModifiedBy()
250 {
251 if (is_null($this->lastModifiedBy)) {
253 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
254 if (is_null($data)) {
255 return null;
256 }
257
258 $this->lastModifiedBy = LastModifiedByModel::of($data);
259 }
260
262 }
263
270 public function getCreatedBy()
271 {
272 if (is_null($this->createdBy)) {
274 $data = $this->raw(self::FIELD_CREATED_BY);
275 if (is_null($data)) {
276 return null;
277 }
278
279 $this->createdBy = CreatedByModel::of($data);
280 }
281
282 return $this->createdBy;
283 }
284
291 public function getKey()
292 {
293 if (is_null($this->key)) {
295 $data = $this->raw(self::FIELD_KEY);
296 if (is_null($data)) {
297 return null;
298 }
299 $this->key = (string) $data;
300 }
301
302 return $this->key;
303 }
304
311 public function getName()
312 {
313 if (is_null($this->name)) {
315 $data = $this->raw(self::FIELD_NAME);
316 if (is_null($data)) {
317 return null;
318 }
319
320 $this->name = LocalizedStringModel::of($data);
321 }
322
323 return $this->name;
324 }
325
332 public function getLanguages()
333 {
334 if (is_null($this->languages)) {
336 $data = $this->raw(self::FIELD_LANGUAGES);
337 if (is_null($data)) {
338 return null;
339 }
340 $this->languages = $data;
341 }
342
343 return $this->languages;
344 }
345
352 public function getCountries()
353 {
354 if (is_null($this->countries)) {
356 $data = $this->raw(self::FIELD_COUNTRIES);
357 if (is_null($data)) {
358 return null;
359 }
360 $this->countries = StoreCountryCollection::fromArray($data);
361 }
362
363 return $this->countries;
364 }
365
372 public function getDistributionChannels()
373 {
374 if (is_null($this->distributionChannels)) {
376 $data = $this->raw(self::FIELD_DISTRIBUTION_CHANNELS);
377 if (is_null($data)) {
378 return null;
379 }
380 $this->distributionChannels = ChannelReferenceCollection::fromArray($data);
381 }
382
384 }
385
392 public function getSupplyChannels()
393 {
394 if (is_null($this->supplyChannels)) {
396 $data = $this->raw(self::FIELD_SUPPLY_CHANNELS);
397 if (is_null($data)) {
398 return null;
399 }
400 $this->supplyChannels = ChannelReferenceCollection::fromArray($data);
401 }
402
404 }
405
418 public function getProductSelections()
419 {
420 if (is_null($this->productSelections)) {
422 $data = $this->raw(self::FIELD_PRODUCT_SELECTIONS);
423 if (is_null($data)) {
424 return null;
425 }
426 $this->productSelections = ProductSelectionSettingCollection::fromArray($data);
427 }
428
430 }
431
438 public function getCustom()
439 {
440 if (is_null($this->custom)) {
442 $data = $this->raw(self::FIELD_CUSTOM);
443 if (is_null($data)) {
444 return null;
445 }
446
447 $this->custom = CustomFieldsModel::of($data);
448 }
449
450 return $this->custom;
451 }
452
453
457 public function setId(?string $id): void
458 {
459 $this->id = $id;
460 }
461
465 public function setVersion(?int $version): void
466 {
467 $this->version = $version;
468 }
469
473 public function setCreatedAt(?DateTimeImmutable $createdAt): void
474 {
475 $this->createdAt = $createdAt;
476 }
477
481 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
482 {
483 $this->lastModifiedAt = $lastModifiedAt;
484 }
485
490 {
491 $this->lastModifiedBy = $lastModifiedBy;
492 }
493
497 public function setCreatedBy(?CreatedBy $createdBy): void
498 {
499 $this->createdBy = $createdBy;
500 }
501
505 public function setKey(?string $key): void
506 {
507 $this->key = $key;
508 }
509
513 public function setName(?LocalizedString $name): void
514 {
515 $this->name = $name;
516 }
517
521 public function setLanguages(?array $languages): void
522 {
523 $this->languages = $languages;
524 }
525
530 {
531 $this->countries = $countries;
532 }
533
538 {
539 $this->distributionChannels = $distributionChannels;
540 }
541
546 {
547 $this->supplyChannels = $supplyChannels;
548 }
549
554 {
555 $this->productSelections = $productSelections;
556 }
557
561 public function setCustom(?CustomFields $custom): void
562 {
563 $this->custom = $custom;
564 }
565
566
567 #[\ReturnTypeWillChange]
568 public function jsonSerialize()
569 {
570 $data = $this->toArray();
571 if (isset($data[Store::FIELD_CREATED_AT]) && $data[Store::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
572 $data[Store::FIELD_CREATED_AT] = $data[Store::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
573 }
574
575 if (isset($data[Store::FIELD_LAST_MODIFIED_AT]) && $data[Store::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
576 $data[Store::FIELD_LAST_MODIFIED_AT] = $data[Store::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
577 }
578 return (object) $data;
579 }
580}
setSupplyChannels(?ChannelReferenceCollection $supplyChannels)
__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)
setCreatedAt(?DateTimeImmutable $createdAt)
setCountries(?StoreCountryCollection $countries)
setProductSelections(?ProductSelectionSettingCollection $productSelections)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setDistributionChannels(?ChannelReferenceCollection $distributionChannels)
static fromArray(array $data)