commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ReviewStateTransitionMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use DateTimeImmutable;
24 use stdClass;
25 
30 {
31  public const DISCRIMINATOR_VALUE = 'ReviewStateTransition';
36  protected $id;
37 
42  protected $version;
43 
48  protected $createdAt;
49 
54  protected $lastModifiedAt;
55 
60  protected $lastModifiedBy;
61 
66  protected $createdBy;
67 
72  protected $sequenceNumber;
73 
78  protected $resource;
79 
84  protected $resourceVersion;
85 
90  protected $type;
91 
97 
102  protected $oldState;
103 
108  protected $newState;
109 
115 
121 
126  protected $target;
127 
132  protected $force;
133 
134 
138  public function __construct(
139  ?string $id = null,
140  ?int $version = null,
141  ?DateTimeImmutable $createdAt = null,
142  ?DateTimeImmutable $lastModifiedAt = null,
144  ?CreatedBy $createdBy = null,
145  ?int $sequenceNumber = null,
146  ?Reference $resource = null,
147  ?int $resourceVersion = null,
149  ?StateReference $oldState = null,
150  ?StateReference $newState = null,
151  ?bool $oldIncludedInStatistics = null,
152  ?bool $newIncludedInStatistics = null,
153  ?Reference $target = null,
154  ?bool $force = null,
155  ?string $type = null
156  ) {
157  $this->id = $id;
158  $this->version = $version;
159  $this->createdAt = $createdAt;
160  $this->lastModifiedAt = $lastModifiedAt;
161  $this->lastModifiedBy = $lastModifiedBy;
162  $this->createdBy = $createdBy;
163  $this->sequenceNumber = $sequenceNumber;
164  $this->resource = $resource;
165  $this->resourceVersion = $resourceVersion;
166  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
167  $this->oldState = $oldState;
168  $this->newState = $newState;
169  $this->oldIncludedInStatistics = $oldIncludedInStatistics;
170  $this->newIncludedInStatistics = $newIncludedInStatistics;
171  $this->target = $target;
172  $this->force = $force;
173  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
174  }
175 
182  public function getId()
183  {
184  if (is_null($this->id)) {
186  $data = $this->raw(self::FIELD_ID);
187  if (is_null($data)) {
188  return null;
189  }
190  $this->id = (string) $data;
191  }
192 
193  return $this->id;
194  }
195 
202  public function getVersion()
203  {
204  if (is_null($this->version)) {
206  $data = $this->raw(self::FIELD_VERSION);
207  if (is_null($data)) {
208  return null;
209  }
210  $this->version = (int) $data;
211  }
212 
213  return $this->version;
214  }
215 
222  public function getCreatedAt()
223  {
224  if (is_null($this->createdAt)) {
226  $data = $this->raw(self::FIELD_CREATED_AT);
227  if (is_null($data)) {
228  return null;
229  }
230  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
231  if (false === $data) {
232  return null;
233  }
234  $this->createdAt = $data;
235  }
236 
237  return $this->createdAt;
238  }
239 
246  public function getLastModifiedAt()
247  {
248  if (is_null($this->lastModifiedAt)) {
250  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
251  if (is_null($data)) {
252  return null;
253  }
254  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
255  if (false === $data) {
256  return null;
257  }
258  $this->lastModifiedAt = $data;
259  }
260 
261  return $this->lastModifiedAt;
262  }
263 
270  public function getLastModifiedBy()
271  {
272  if (is_null($this->lastModifiedBy)) {
274  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
275  if (is_null($data)) {
276  return null;
277  }
278 
279  $this->lastModifiedBy = LastModifiedByModel::of($data);
280  }
281 
282  return $this->lastModifiedBy;
283  }
284 
291  public function getCreatedBy()
292  {
293  if (is_null($this->createdBy)) {
295  $data = $this->raw(self::FIELD_CREATED_BY);
296  if (is_null($data)) {
297  return null;
298  }
299 
300  $this->createdBy = CreatedByModel::of($data);
301  }
302 
303  return $this->createdBy;
304  }
305 
313  public function getSequenceNumber()
314  {
315  if (is_null($this->sequenceNumber)) {
317  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
318  if (is_null($data)) {
319  return null;
320  }
321  $this->sequenceNumber = (int) $data;
322  }
323 
324  return $this->sequenceNumber;
325  }
326 
333  public function getResource()
334  {
335  if (is_null($this->resource)) {
337  $data = $this->raw(self::FIELD_RESOURCE);
338  if (is_null($data)) {
339  return null;
340  }
341  $className = ReferenceModel::resolveDiscriminatorClass($data);
342  $this->resource = $className::of($data);
343  }
344 
345  return $this->resource;
346  }
347 
354  public function getResourceVersion()
355  {
356  if (is_null($this->resourceVersion)) {
358  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
359  if (is_null($data)) {
360  return null;
361  }
362  $this->resourceVersion = (int) $data;
363  }
364 
365  return $this->resourceVersion;
366  }
367 
374  public function getType()
375  {
376  if (is_null($this->type)) {
378  $data = $this->raw(self::FIELD_TYPE);
379  if (is_null($data)) {
380  return null;
381  }
382  $this->type = (string) $data;
383  }
384 
385  return $this->type;
386  }
387 
395  {
396  if (is_null($this->resourceUserProvidedIdentifiers)) {
398  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
399  if (is_null($data)) {
400  return null;
401  }
402 
403  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
404  }
405 
407  }
408 
415  public function getOldState()
416  {
417  if (is_null($this->oldState)) {
419  $data = $this->raw(self::FIELD_OLD_STATE);
420  if (is_null($data)) {
421  return null;
422  }
423 
424  $this->oldState = StateReferenceModel::of($data);
425  }
426 
427  return $this->oldState;
428  }
429 
436  public function getNewState()
437  {
438  if (is_null($this->newState)) {
440  $data = $this->raw(self::FIELD_NEW_STATE);
441  if (is_null($data)) {
442  return null;
443  }
444 
445  $this->newState = StateReferenceModel::of($data);
446  }
447 
448  return $this->newState;
449  }
450 
457  public function getOldIncludedInStatistics()
458  {
459  if (is_null($this->oldIncludedInStatistics)) {
461  $data = $this->raw(self::FIELD_OLD_INCLUDED_IN_STATISTICS);
462  if (is_null($data)) {
463  return null;
464  }
465  $this->oldIncludedInStatistics = (bool) $data;
466  }
467 
469  }
470 
477  public function getNewIncludedInStatistics()
478  {
479  if (is_null($this->newIncludedInStatistics)) {
481  $data = $this->raw(self::FIELD_NEW_INCLUDED_IN_STATISTICS);
482  if (is_null($data)) {
483  return null;
484  }
485  $this->newIncludedInStatistics = (bool) $data;
486  }
487 
489  }
490 
497  public function getTarget()
498  {
499  if (is_null($this->target)) {
501  $data = $this->raw(self::FIELD_TARGET);
502  if (is_null($data)) {
503  return null;
504  }
505  $className = ReferenceModel::resolveDiscriminatorClass($data);
506  $this->target = $className::of($data);
507  }
508 
509  return $this->target;
510  }
511 
518  public function getForce()
519  {
520  if (is_null($this->force)) {
522  $data = $this->raw(self::FIELD_FORCE);
523  if (is_null($data)) {
524  return null;
525  }
526  $this->force = (bool) $data;
527  }
528 
529  return $this->force;
530  }
531 
532 
536  public function setId(?string $id): void
537  {
538  $this->id = $id;
539  }
540 
544  public function setVersion(?int $version): void
545  {
546  $this->version = $version;
547  }
548 
552  public function setCreatedAt(?DateTimeImmutable $createdAt): void
553  {
554  $this->createdAt = $createdAt;
555  }
556 
560  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
561  {
562  $this->lastModifiedAt = $lastModifiedAt;
563  }
564 
569  {
570  $this->lastModifiedBy = $lastModifiedBy;
571  }
572 
576  public function setCreatedBy(?CreatedBy $createdBy): void
577  {
578  $this->createdBy = $createdBy;
579  }
580 
584  public function setSequenceNumber(?int $sequenceNumber): void
585  {
586  $this->sequenceNumber = $sequenceNumber;
587  }
588 
592  public function setResource(?Reference $resource): void
593  {
594  $this->resource = $resource;
595  }
596 
600  public function setResourceVersion(?int $resourceVersion): void
601  {
602  $this->resourceVersion = $resourceVersion;
603  }
604 
609  {
610  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
611  }
612 
616  public function setOldState(?StateReference $oldState): void
617  {
618  $this->oldState = $oldState;
619  }
620 
624  public function setNewState(?StateReference $newState): void
625  {
626  $this->newState = $newState;
627  }
628 
633  {
634  $this->oldIncludedInStatistics = $oldIncludedInStatistics;
635  }
636 
641  {
642  $this->newIncludedInStatistics = $newIncludedInStatistics;
643  }
644 
648  public function setTarget(?Reference $target): void
649  {
650  $this->target = $target;
651  }
652 
656  public function setForce(?bool $force): void
657  {
658  $this->force = $force;
659  }
660 
661 
662  #[\ReturnTypeWillChange]
663  public function jsonSerialize()
664  {
665  $data = $this->toArray();
666  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
667  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
668  }
669 
670  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
671  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
672  }
673  return (object) $data;
674  }
675 }
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, ?StateReference $oldState=null, ?StateReference $newState=null, ?bool $oldIncludedInStatistics=null, ?bool $newIncludedInStatistics=null, ?Reference $target=null, ?bool $force=null, ?string $type=null)