commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ReviewRatingSetMessageModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
21 use DateTimeImmutable;
22 use stdClass;
23 
28 {
29  public const DISCRIMINATOR_VALUE = 'ReviewRatingSet';
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 $oldRating;
101 
106  protected $newRating;
107 
113 
118  protected $target;
119 
120 
124  public function __construct(
125  ?string $id = null,
126  ?int $version = null,
127  ?DateTimeImmutable $createdAt = null,
128  ?DateTimeImmutable $lastModifiedAt = null,
130  ?CreatedBy $createdBy = null,
131  ?int $sequenceNumber = null,
132  ?Reference $resource = null,
133  ?int $resourceVersion = null,
135  ?float $oldRating = null,
136  ?float $newRating = null,
137  ?bool $includedInStatistics = null,
138  ?Reference $target = null,
139  ?string $type = null
140  ) {
141  $this->id = $id;
142  $this->version = $version;
143  $this->createdAt = $createdAt;
144  $this->lastModifiedAt = $lastModifiedAt;
145  $this->lastModifiedBy = $lastModifiedBy;
146  $this->createdBy = $createdBy;
147  $this->sequenceNumber = $sequenceNumber;
148  $this->resource = $resource;
149  $this->resourceVersion = $resourceVersion;
150  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
151  $this->oldRating = $oldRating;
152  $this->newRating = $newRating;
153  $this->includedInStatistics = $includedInStatistics;
154  $this->target = $target;
155  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
156  }
157 
164  public function getId()
165  {
166  if (is_null($this->id)) {
168  $data = $this->raw(self::FIELD_ID);
169  if (is_null($data)) {
170  return null;
171  }
172  $this->id = (string) $data;
173  }
174 
175  return $this->id;
176  }
177 
184  public function getVersion()
185  {
186  if (is_null($this->version)) {
188  $data = $this->raw(self::FIELD_VERSION);
189  if (is_null($data)) {
190  return null;
191  }
192  $this->version = (int) $data;
193  }
194 
195  return $this->version;
196  }
197 
204  public function getCreatedAt()
205  {
206  if (is_null($this->createdAt)) {
208  $data = $this->raw(self::FIELD_CREATED_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->createdAt = $data;
217  }
218 
219  return $this->createdAt;
220  }
221 
228  public function getLastModifiedAt()
229  {
230  if (is_null($this->lastModifiedAt)) {
232  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
233  if (is_null($data)) {
234  return null;
235  }
236  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
237  if (false === $data) {
238  return null;
239  }
240  $this->lastModifiedAt = $data;
241  }
242 
243  return $this->lastModifiedAt;
244  }
245 
252  public function getLastModifiedBy()
253  {
254  if (is_null($this->lastModifiedBy)) {
256  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
257  if (is_null($data)) {
258  return null;
259  }
260 
261  $this->lastModifiedBy = LastModifiedByModel::of($data);
262  }
263 
264  return $this->lastModifiedBy;
265  }
266 
273  public function getCreatedBy()
274  {
275  if (is_null($this->createdBy)) {
277  $data = $this->raw(self::FIELD_CREATED_BY);
278  if (is_null($data)) {
279  return null;
280  }
281 
282  $this->createdBy = CreatedByModel::of($data);
283  }
284 
285  return $this->createdBy;
286  }
287 
295  public function getSequenceNumber()
296  {
297  if (is_null($this->sequenceNumber)) {
299  $data = $this->raw(self::FIELD_SEQUENCE_NUMBER);
300  if (is_null($data)) {
301  return null;
302  }
303  $this->sequenceNumber = (int) $data;
304  }
305 
306  return $this->sequenceNumber;
307  }
308 
315  public function getResource()
316  {
317  if (is_null($this->resource)) {
319  $data = $this->raw(self::FIELD_RESOURCE);
320  if (is_null($data)) {
321  return null;
322  }
323  $className = ReferenceModel::resolveDiscriminatorClass($data);
324  $this->resource = $className::of($data);
325  }
326 
327  return $this->resource;
328  }
329 
336  public function getResourceVersion()
337  {
338  if (is_null($this->resourceVersion)) {
340  $data = $this->raw(self::FIELD_RESOURCE_VERSION);
341  if (is_null($data)) {
342  return null;
343  }
344  $this->resourceVersion = (int) $data;
345  }
346 
347  return $this->resourceVersion;
348  }
349 
356  public function getType()
357  {
358  if (is_null($this->type)) {
360  $data = $this->raw(self::FIELD_TYPE);
361  if (is_null($data)) {
362  return null;
363  }
364  $this->type = (string) $data;
365  }
366 
367  return $this->type;
368  }
369 
377  {
378  if (is_null($this->resourceUserProvidedIdentifiers)) {
380  $data = $this->raw(self::FIELD_RESOURCE_USER_PROVIDED_IDENTIFIERS);
381  if (is_null($data)) {
382  return null;
383  }
384 
385  $this->resourceUserProvidedIdentifiers = UserProvidedIdentifiersModel::of($data);
386  }
387 
389  }
390 
397  public function getOldRating()
398  {
399  if (is_null($this->oldRating)) {
401  $data = $this->raw(self::FIELD_OLD_RATING);
402  if (is_null($data)) {
403  return null;
404  }
405  $this->oldRating = (float) $data;
406  }
407 
408  return $this->oldRating;
409  }
410 
417  public function getNewRating()
418  {
419  if (is_null($this->newRating)) {
421  $data = $this->raw(self::FIELD_NEW_RATING);
422  if (is_null($data)) {
423  return null;
424  }
425  $this->newRating = (float) $data;
426  }
427 
428  return $this->newRating;
429  }
430 
437  public function getIncludedInStatistics()
438  {
439  if (is_null($this->includedInStatistics)) {
441  $data = $this->raw(self::FIELD_INCLUDED_IN_STATISTICS);
442  if (is_null($data)) {
443  return null;
444  }
445  $this->includedInStatistics = (bool) $data;
446  }
447 
449  }
450 
457  public function getTarget()
458  {
459  if (is_null($this->target)) {
461  $data = $this->raw(self::FIELD_TARGET);
462  if (is_null($data)) {
463  return null;
464  }
465  $className = ReferenceModel::resolveDiscriminatorClass($data);
466  $this->target = $className::of($data);
467  }
468 
469  return $this->target;
470  }
471 
472 
476  public function setId(?string $id): void
477  {
478  $this->id = $id;
479  }
480 
484  public function setVersion(?int $version): void
485  {
486  $this->version = $version;
487  }
488 
492  public function setCreatedAt(?DateTimeImmutable $createdAt): void
493  {
494  $this->createdAt = $createdAt;
495  }
496 
500  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
501  {
502  $this->lastModifiedAt = $lastModifiedAt;
503  }
504 
509  {
510  $this->lastModifiedBy = $lastModifiedBy;
511  }
512 
516  public function setCreatedBy(?CreatedBy $createdBy): void
517  {
518  $this->createdBy = $createdBy;
519  }
520 
524  public function setSequenceNumber(?int $sequenceNumber): void
525  {
526  $this->sequenceNumber = $sequenceNumber;
527  }
528 
532  public function setResource(?Reference $resource): void
533  {
534  $this->resource = $resource;
535  }
536 
540  public function setResourceVersion(?int $resourceVersion): void
541  {
542  $this->resourceVersion = $resourceVersion;
543  }
544 
549  {
550  $this->resourceUserProvidedIdentifiers = $resourceUserProvidedIdentifiers;
551  }
552 
556  public function setOldRating(?float $oldRating): void
557  {
558  $this->oldRating = $oldRating;
559  }
560 
564  public function setNewRating(?float $newRating): void
565  {
566  $this->newRating = $newRating;
567  }
568 
572  public function setIncludedInStatistics(?bool $includedInStatistics): void
573  {
574  $this->includedInStatistics = $includedInStatistics;
575  }
576 
580  public function setTarget(?Reference $target): void
581  {
582  $this->target = $target;
583  }
584 
585 
586  #[\ReturnTypeWillChange]
587  public function jsonSerialize()
588  {
589  $data = $this->toArray();
590  if (isset($data[Message::FIELD_CREATED_AT]) && $data[Message::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
591  $data[Message::FIELD_CREATED_AT] = $data[Message::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
592  }
593 
594  if (isset($data[Message::FIELD_LAST_MODIFIED_AT]) && $data[Message::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
595  $data[Message::FIELD_LAST_MODIFIED_AT] = $data[Message::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
596  }
597  return (object) $data;
598  }
599 }
__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, ?float $oldRating=null, ?float $newRating=null, ?bool $includedInStatistics=null, ?Reference $target=null, ?string $type=null)
setResourceUserProvidedIdentifiers(?UserProvidedIdentifiers $resourceUserProvidedIdentifiers)