commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CustomerTitleSetMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
21 use DateTimeImmutable;
22 use stdClass;
23 
28 {
29  public const DISCRIMINATOR_VALUE = 'CustomerTitleSet';
34  protected $id;
35 
40  protected $version;
41 
46  protected $createdAt;
47 
52  protected $lastModifiedAt;
53 
58  protected $lastModifiedBy;
59 
64  protected $createdBy;
65 
70  protected $sequenceNumber;
71 
76  protected $resource;
77 
82  protected $resourceVersion;
83 
88  protected $type;
89 
95 
100  protected $title;
101 
102 
106  public function __construct(
107  ?string $id = null,
108  ?int $version = null,
109  ?DateTimeImmutable $createdAt = null,
110  ?DateTimeImmutable $lastModifiedAt = null,
112  ?CreatedBy $createdBy = null,
113  ?int $sequenceNumber = null,
114  ?Reference $resource = null,
115  ?int $resourceVersion = null,
117  ?string $title = null,
118  ?string $type = null
119  ) {
120  $this->id = $id;
121  $this->version = $version;
122  $this->createdAt = $createdAt;
123  $this->lastModifiedAt = $lastModifiedAt;
124  $this->lastModifiedBy = $lastModifiedBy;
125  $this->createdBy = $createdBy;
126  $this->sequenceNumber = $sequenceNumber;
127  $this->resource = $resource;
128  $this->resourceVersion = $resourceVersion;
129  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
130  $this->title = $title;
131  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
132  }
133 
140  public function getId()
141  {
142  if (is_null($this->id)) {
144  $data = $this->raw(self::FIELD_ID);
145  if (is_null($data)) {
146  return null;
147  }
148  $this->id = (string) $data;
149  }
150 
151  return $this->id;
152  }
153 
160  public function getVersion()
161  {
162  if (is_null($this->version)) {
164  $data = $this->raw(self::FIELD_VERSION);
165  if (is_null($data)) {
166  return null;
167  }
168  $this->version = (int) $data;
169  }
170 
171  return $this->version;
172  }
173 
180  public function getCreatedAt()
181  {
182  if (is_null($this->createdAt)) {
184  $data = $this->raw(self::FIELD_CREATED_AT);
185  if (is_null($data)) {
186  return null;
187  }
188  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
189  if (false === $data) {
190  return null;
191  }
192  $this->createdAt = $data;
193  }
194 
195  return $this->createdAt;
196  }
197 
204  public function getLastModifiedAt()
205  {
206  if (is_null($this->lastModifiedAt)) {
208  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
209  if (is_null($data)) {
210  return null;
211  }
212  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
213  if (false === $data) {
214  return null;
215  }
216  $this->lastModifiedAt = $data;
217  }
218 
219  return $this->lastModifiedAt;
220  }
221 
228  public function getLastModifiedBy()
229  {
230  if (is_null($this->lastModifiedBy)) {
232  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
233  if (is_null($data)) {
234  return null;
235  }
236 
237  $this->lastModifiedBy = LastModifiedByModel::of($data);
238  }
239 
240  return $this->lastModifiedBy;
241  }
242 
249  public function getCreatedBy()
250  {
251  if (is_null($this->createdBy)) {
253  $data = $this->raw(self::FIELD_CREATED_BY);
254  if (is_null($data)) {
255  return null;
256  }
257 
258  $this->createdBy = CreatedByModel::of($data);
259  }
260 
261  return $this->createdBy;
262  }
263 
271  public function getSequenceNumber()
272  {
273  if (is_null($this->sequenceNumber)) {
275  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
276  if (is_null($data)) {
277  return null;
278  }
279  $this->sequenceNumber = (int) $data;
280  }
281 
282  return $this->sequenceNumber;
283  }
284 
291  public function getResource()
292  {
293  if (is_null($this->resource)) {
295  $data = $this->raw(self::FIELD_RESOURCE);
296  if (is_null($data)) {
297  return null;
298  }
299  $className = ReferenceModel::resolveDiscriminatorClass($data);
300  $this->resource = $className::of($data);
301  }
302 
303  return $this->resource;
304  }
305 
312  public function getResourceVersion()
313  {
314  if (is_null($this->resourceVersion)) {
316  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
317  if (is_null($data)) {
318  return null;
319  }
320  $this->resourceVersion = (int) $data;
321  }
322 
323  return $this->resourceVersion;
324  }
325 
332  public function getType()
333  {
334  if (is_null($this->type)) {
336  $data = $this->raw(self::FIELD_TYPE);
337  if (is_null($data)) {
338  return null;
339  }
340  $this->type = (string) $data;
341  }
342 
343  return $this->type;
344  }
345 
353  {
354  if (is_null($this->resourceUserProvidedIdentifiers)) {
356  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
357  if (is_null($data)) {
358  return null;
359  }
360 
361  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
362  }
363 
365  }
366 
373  public function getTitle()
374  {
375  if (is_null($this->title)) {
377  $data = $this->raw(self::FIELD_TITLE);
378  if (is_null($data)) {
379  return null;
380  }
381  $this->title = (string) $data;
382  }
383 
384  return $this->title;
385  }
386 
387 
391  public function setId(?string $id): void
392  {
393  $this->id = $id;
394  }
395 
399  public function setVersion(?int $version): void
400  {
401  $this->version = $version;
402  }
403 
407  public function setCreatedAt(?DateTimeImmutable $createdAt): void
408  {
409  $this->createdAt = $createdAt;
410  }
411 
415  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
416  {
417  $this->lastModifiedAt = $lastModifiedAt;
418  }
419 
424  {
425  $this->lastModifiedBy = $lastModifiedBy;
426  }
427 
431  public function setCreatedBy(?CreatedBy $createdBy): void
432  {
433  $this->createdBy = $createdBy;
434  }
435 
439  public function setSequenceNumber(?int $sequenceNumber): void
440  {
441  $this->sequenceNumber = $sequenceNumber;
442  }
443 
447  public function setResource(?Reference $resource): void
448  {
449  $this->resource = $resource;
450  }
451 
455  public function setResourceVersion(?int $resourceVersion): void
456  {
457  $this->resourceVersion = $resourceVersion;
458  }
459 
464  {
465  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
466  }
467 
471  public function setTitle(?string $title): void
472  {
473  $this->title = $title;
474  }
475 
476 
477  #[\ReturnTypeWillChange]
478  public function jsonSerialize()
479  {
480  $data = $this->toArray();
481  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
482  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
483  }
484 
485  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
486  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
487  }
488  return (object) $data;
489  }
490 }
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, ?string $title=null, ?string $type=null)