commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
StoreNameSetMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
24 use DateTimeImmutable;
25 use stdClass;
26 
31 {
32  public const DISCRIMINATOR_VALUE = 'StoreNameSet';
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 
85  protected $resourceVersion;
86 
91  protected $type;
92 
98 
103  protected $name;
104 
109  protected $nameAllLocales;
110 
111 
115  public function __construct(
116  ?string $id = null,
117  ?int $version = null,
118  ?DateTimeImmutable $createdAt = null,
119  ?DateTimeImmutable $lastModifiedAt = null,
121  ?CreatedBy $createdBy = null,
122  ?int $sequenceNumber = null,
123  ?Reference $resource = null,
124  ?int $resourceVersion = null,
126  ?LocalizedString $name = null,
128  ?string $type = null
129  ) {
130  $this->id = $id;
131  $this->version = $version;
132  $this->createdAt = $createdAt;
133  $this->lastModifiedAt = $lastModifiedAt;
134  $this->lastModifiedBy = $lastModifiedBy;
135  $this->createdBy = $createdBy;
136  $this->sequenceNumber = $sequenceNumber;
137  $this->resource = $resource;
138  $this->resourceVersion = $resourceVersion;
139  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
140  $this->name = $name;
141  $this->nameAllLocales = $nameAllLocales;
142  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
143  }
144 
151  public function getId()
152  {
153  if (is_null($this->id)) {
155  $data = $this->raw(self::FIELD_ID);
156  if (is_null($data)) {
157  return null;
158  }
159  $this->id = (string) $data;
160  }
161 
162  return $this->id;
163  }
164 
171  public function getVersion()
172  {
173  if (is_null($this->version)) {
175  $data = $this->raw(self::FIELD_VERSION);
176  if (is_null($data)) {
177  return null;
178  }
179  $this->version = (int) $data;
180  }
181 
182  return $this->version;
183  }
184 
191  public function getCreatedAt()
192  {
193  if (is_null($this->createdAt)) {
195  $data = $this->raw(self::FIELD_CREATED_AT);
196  if (is_null($data)) {
197  return null;
198  }
199  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
200  if (false === $data) {
201  return null;
202  }
203  $this->createdAt = $data;
204  }
205 
206  return $this->createdAt;
207  }
208 
215  public function getLastModifiedAt()
216  {
217  if (is_null($this->lastModifiedAt)) {
219  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
220  if (is_null($data)) {
221  return null;
222  }
223  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
224  if (false === $data) {
225  return null;
226  }
227  $this->lastModifiedAt = $data;
228  }
229 
230  return $this->lastModifiedAt;
231  }
232 
239  public function getLastModifiedBy()
240  {
241  if (is_null($this->lastModifiedBy)) {
243  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
244  if (is_null($data)) {
245  return null;
246  }
247 
248  $this->lastModifiedBy = LastModifiedByModel::of($data);
249  }
250 
251  return $this->lastModifiedBy;
252  }
253 
260  public function getCreatedBy()
261  {
262  if (is_null($this->createdBy)) {
264  $data = $this->raw(self::FIELD_CREATED_BY);
265  if (is_null($data)) {
266  return null;
267  }
268 
269  $this->createdBy = CreatedByModel::of($data);
270  }
271 
272  return $this->createdBy;
273  }
274 
282  public function getSequenceNumber()
283  {
284  if (is_null($this->sequenceNumber)) {
286  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
287  if (is_null($data)) {
288  return null;
289  }
290  $this->sequenceNumber = (int) $data;
291  }
292 
293  return $this->sequenceNumber;
294  }
295 
302  public function getResource()
303  {
304  if (is_null($this->resource)) {
306  $data = $this->raw(self::FIELD_RESOURCE);
307  if (is_null($data)) {
308  return null;
309  }
310  $className = ReferenceModel::resolveDiscriminatorClass($data);
311  $this->resource = $className::of($data);
312  }
313 
314  return $this->resource;
315  }
316 
323  public function getResourceVersion()
324  {
325  if (is_null($this->resourceVersion)) {
327  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
328  if (is_null($data)) {
329  return null;
330  }
331  $this->resourceVersion = (int) $data;
332  }
333 
334  return $this->resourceVersion;
335  }
336 
343  public function getType()
344  {
345  if (is_null($this->type)) {
347  $data = $this->raw(self::FIELD_TYPE);
348  if (is_null($data)) {
349  return null;
350  }
351  $this->type = (string) $data;
352  }
353 
354  return $this->type;
355  }
356 
364  {
365  if (is_null($this->resourceUserProvidedIdentifiers)) {
367  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
368  if (is_null($data)) {
369  return null;
370  }
371 
372  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
373  }
374 
376  }
377 
384  public function getName()
385  {
386  if (is_null($this->name)) {
388  $data = $this->raw(self::FIELD_NAME);
389  if (is_null($data)) {
390  return null;
391  }
392 
393  $this->name = LocalizedStringModel::of($data);
394  }
395 
396  return $this->name;
397  }
398 
405  public function getNameAllLocales()
406  {
407  if (is_null($this->nameAllLocales)) {
409  $data = $this->raw(self::FIELD_NAME_ALL_LOCALES);
410  if (is_null($data)) {
411  return null;
412  }
413  $this->nameAllLocales = LocalizedStringCollection::fromArray($data);
414  }
415 
416  return $this->nameAllLocales;
417  }
418 
419 
423  public function setId(?string $id): void
424  {
425  $this->id = $id;
426  }
427 
431  public function setVersion(?int $version): void
432  {
433  $this->version = $version;
434  }
435 
439  public function setCreatedAt(?DateTimeImmutable $createdAt): void
440  {
441  $this->createdAt = $createdAt;
442  }
443 
447  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
448  {
449  $this->lastModifiedAt = $lastModifiedAt;
450  }
451 
456  {
457  $this->lastModifiedBy = $lastModifiedBy;
458  }
459 
463  public function setCreatedBy(?CreatedBy $createdBy): void
464  {
465  $this->createdBy = $createdBy;
466  }
467 
471  public function setSequenceNumber(?int $sequenceNumber): void
472  {
473  $this->sequenceNumber = $sequenceNumber;
474  }
475 
479  public function setResource(?Reference $resource): void
480  {
481  $this->resource = $resource;
482  }
483 
487  public function setResourceVersion(?int $resourceVersion): void
488  {
489  $this->resourceVersion = $resourceVersion;
490  }
491 
496  {
497  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
498  }
499 
503  public function setName(?LocalizedString $name): void
504  {
505  $this->name = $name;
506  }
507 
512  {
513  $this->nameAllLocales = $nameAllLocales;
514  }
515 
516 
517  #[\ReturnTypeWillChange]
518  public function jsonSerialize()
519  {
520  $data = $this->toArray();
521  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
522  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
523  }
524 
525  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
526  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
527  }
528  return (object) $data;
529  }
530 }
setNameAllLocales(?LocalizedStringCollection $nameAllLocales)
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, ?LocalizedString $name=null, ?LocalizedStringCollection $nameAllLocales=null, ?string $type=null)
static of($data=null)
Definition: MapperMap.php:45