commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ReviewModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
31 use DateTimeImmutable;
32 use stdClass;
33 
37 final class ReviewModel extends JsonObjectModel implements Review
38 {
43  protected $id;
44 
49  protected $version;
50 
55  protected $createdAt;
56 
61  protected $lastModifiedAt;
62 
67  protected $lastModifiedBy;
68 
73  protected $createdBy;
74 
79  protected $key;
80 
85  protected $uniquenessValue;
86 
91  protected $locale;
92 
97  protected $authorName;
98 
103  protected $title;
104 
109  protected $text;
110 
115  protected $target;
116 
122 
127  protected $rating;
128 
133  protected $state;
134 
139  protected $customer;
140 
145  protected $custom;
146 
147 
151  public function __construct(
152  ?string $id = null,
153  ?int $version = null,
154  ?DateTimeImmutable $createdAt = null,
155  ?DateTimeImmutable $lastModifiedAt = null,
157  ?CreatedBy $createdBy = null,
158  ?string $key = null,
159  ?string $uniquenessValue = null,
160  ?string $locale = null,
161  ?string $authorName = null,
162  ?string $title = null,
163  ?string $text = null,
164  ?JsonObject $target = null,
165  ?bool $includedInStatistics = null,
166  ?int $rating = null,
167  ?StateReference $state = null,
169  ?CustomFields $custom = null
170  ) {
171  $this->id = $id;
172  $this->version = $version;
173  $this->createdAt = $createdAt;
174  $this->lastModifiedAt = $lastModifiedAt;
175  $this->lastModifiedBy = $lastModifiedBy;
176  $this->createdBy = $createdBy;
177  $this->key = $key;
178  $this->uniquenessValue = $uniquenessValue;
179  $this->locale = $locale;
180  $this->authorName = $authorName;
181  $this->title = $title;
182  $this->text = $text;
183  $this->target = $target;
184  $this->includedInStatistics = $includedInStatistics;
185  $this->rating = $rating;
186  $this->state = $state;
187  $this->customer = $customer;
188  $this->custom = $custom;
189  }
190 
197  public function getId()
198  {
199  if (is_null($this->id)) {
201  $data = $this->raw(self::FIELD_ID);
202  if (is_null($data)) {
203  return null;
204  }
205  $this->id = (string) $data;
206  }
207 
208  return $this->id;
209  }
210 
217  public function getVersion()
218  {
219  if (is_null($this->version)) {
221  $data = $this->raw(self::FIELD_VERSION);
222  if (is_null($data)) {
223  return null;
224  }
225  $this->version = (int) $data;
226  }
227 
228  return $this->version;
229  }
230 
237  public function getCreatedAt()
238  {
239  if (is_null($this->createdAt)) {
241  $data = $this->raw(self::FIELD_CREATED_AT);
242  if (is_null($data)) {
243  return null;
244  }
245  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
246  if (false === $data) {
247  return null;
248  }
249  $this->createdAt = $data;
250  }
251 
252  return $this->createdAt;
253  }
254 
261  public function getLastModifiedAt()
262  {
263  if (is_null($this->lastModifiedAt)) {
265  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
266  if (is_null($data)) {
267  return null;
268  }
269  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
270  if (false === $data) {
271  return null;
272  }
273  $this->lastModifiedAt = $data;
274  }
275 
276  return $this->lastModifiedAt;
277  }
278 
285  public function getLastModifiedBy()
286  {
287  if (is_null($this->lastModifiedBy)) {
289  $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
290  if (is_null($data)) {
291  return null;
292  }
293 
294  $this->lastModifiedBy = LastModifiedByModel::of($data);
295  }
296 
297  return $this->lastModifiedBy;
298  }
299 
306  public function getCreatedBy()
307  {
308  if (is_null($this->createdBy)) {
310  $data = $this->raw(self::FIELD_CREATED_BY);
311  if (is_null($data)) {
312  return null;
313  }
314 
315  $this->createdBy = CreatedByModel::of($data);
316  }
317 
318  return $this->createdBy;
319  }
320 
327  public function getKey()
328  {
329  if (is_null($this->key)) {
331  $data = $this->raw(self::FIELD_KEY);
332  if (is_null($data)) {
333  return null;
334  }
335  $this->key = (string) $data;
336  }
337 
338  return $this->key;
339  }
340 
347  public function getUniquenessValue()
348  {
349  if (is_null($this->uniquenessValue)) {
351  $data = $this->raw(self::FIELD_UNIQUENESS_VALUE);
352  if (is_null($data)) {
353  return null;
354  }
355  $this->uniquenessValue = (string) $data;
356  }
357 
358  return $this->uniquenessValue;
359  }
360 
367  public function getLocale()
368  {
369  if (is_null($this->locale)) {
371  $data = $this->raw(self::FIELD_LOCALE);
372  if (is_null($data)) {
373  return null;
374  }
375  $this->locale = (string) $data;
376  }
377 
378  return $this->locale;
379  }
380 
387  public function getAuthorName()
388  {
389  if (is_null($this->authorName)) {
391  $data = $this->raw(self::FIELD_AUTHOR_NAME);
392  if (is_null($data)) {
393  return null;
394  }
395  $this->authorName = (string) $data;
396  }
397 
398  return $this->authorName;
399  }
400 
407  public function getTitle()
408  {
409  if (is_null($this->title)) {
411  $data = $this->raw(self::FIELD_TITLE);
412  if (is_null($data)) {
413  return null;
414  }
415  $this->title = (string) $data;
416  }
417 
418  return $this->title;
419  }
420 
427  public function getText()
428  {
429  if (is_null($this->text)) {
431  $data = $this->raw(self::FIELD_TEXT);
432  if (is_null($data)) {
433  return null;
434  }
435  $this->text = (string) $data;
436  }
437 
438  return $this->text;
439  }
440 
447  public function getTarget()
448  {
449  if (is_null($this->target)) {
451  $data = $this->raw(self::FIELD_TARGET);
452  if (is_null($data)) {
453  return null;
454  }
455  $this->target = $data;
456  }
457 
458  return $this->target;
459  }
460 
469  public function getIncludedInStatistics()
470  {
471  if (is_null($this->includedInStatistics)) {
473  $data = $this->raw(self::FIELD_INCLUDED_IN_STATISTICS);
474  if (is_null($data)) {
475  return null;
476  }
477  $this->includedInStatistics = (bool) $data;
478  }
479 
481  }
482 
489  public function getRating()
490  {
491  if (is_null($this->rating)) {
493  $data = $this->raw(self::FIELD_RATING);
494  if (is_null($data)) {
495  return null;
496  }
497  $this->rating = (int) $data;
498  }
499 
500  return $this->rating;
501  }
502 
509  public function getState()
510  {
511  if (is_null($this->state)) {
513  $data = $this->raw(self::FIELD_STATE);
514  if (is_null($data)) {
515  return null;
516  }
517 
518  $this->state = StateReferenceModel::of($data);
519  }
520 
521  return $this->state;
522  }
523 
530  public function getCustomer()
531  {
532  if (is_null($this->customer)) {
534  $data = $this->raw(self::FIELD_CUSTOMER);
535  if (is_null($data)) {
536  return null;
537  }
538 
539  $this->customer = CustomerReferenceModel::of($data);
540  }
541 
542  return $this->customer;
543  }
544 
551  public function getCustom()
552  {
553  if (is_null($this->custom)) {
555  $data = $this->raw(self::FIELD_CUSTOM);
556  if (is_null($data)) {
557  return null;
558  }
559 
560  $this->custom = CustomFieldsModel::of($data);
561  }
562 
563  return $this->custom;
564  }
565 
571  public function getTargetAsProductReference()
572  {
574  $data = $this->raw(self::FIELD_TARGET);
575  if (is_null($data)) {
576  return null;
577  }
578 
579  return ProductReferenceModel::of($data);
580  }
581 
587  public function getTargetAsChannelReference()
588  {
590  $data = $this->raw(self::FIELD_TARGET);
591  if (is_null($data)) {
592  return null;
593  }
594 
595  return ChannelReferenceModel::of($data);
596  }
597 
601  public function setId(?string $id): void
602  {
603  $this->id = $id;
604  }
605 
609  public function setVersion(?int $version): void
610  {
611  $this->version = $version;
612  }
613 
617  public function setCreatedAt(?DateTimeImmutable $createdAt): void
618  {
619  $this->createdAt = $createdAt;
620  }
621 
625  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
626  {
627  $this->lastModifiedAt = $lastModifiedAt;
628  }
629 
634  {
635  $this->lastModifiedBy = $lastModifiedBy;
636  }
637 
641  public function setCreatedBy(?CreatedBy $createdBy): void
642  {
643  $this->createdBy = $createdBy;
644  }
645 
649  public function setKey(?string $key): void
650  {
651  $this->key = $key;
652  }
653 
657  public function setUniquenessValue(?string $uniquenessValue): void
658  {
659  $this->uniquenessValue = $uniquenessValue;
660  }
661 
665  public function setLocale(?string $locale): void
666  {
667  $this->locale = $locale;
668  }
669 
673  public function setAuthorName(?string $authorName): void
674  {
675  $this->authorName = $authorName;
676  }
677 
681  public function setTitle(?string $title): void
682  {
683  $this->title = $title;
684  }
685 
689  public function setText(?string $text): void
690  {
691  $this->text = $text;
692  }
693 
697  public function setTarget(?JsonObject $target): void
698  {
699  $this->target = $target;
700  }
701 
705  public function setIncludedInStatistics(?bool $includedInStatistics): void
706  {
707  $this->includedInStatistics = $includedInStatistics;
708  }
709 
713  public function setRating(?int $rating): void
714  {
715  $this->rating = $rating;
716  }
717 
721  public function setState(?StateReference $state): void
722  {
723  $this->state = $state;
724  }
725 
729  public function setCustomer(?CustomerReference $customer): void
730  {
731  $this->customer = $customer;
732  }
733 
737  public function setCustom(?CustomFields $custom): void
738  {
739  $this->custom = $custom;
740  }
741 
742 
743  #[\ReturnTypeWillChange]
744  public function jsonSerialize()
745  {
746  $data = $this->toArray();
747  if (isset($data[Review::FIELD_CREATED_AT]) && $data[Review::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
748  $data[Review::FIELD_CREATED_AT] = $data[Review::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
749  }
750 
751  if (isset($data[Review::FIELD_LAST_MODIFIED_AT]) && $data[Review::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
752  $data[Review::FIELD_LAST_MODIFIED_AT] = $data[Review::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
753  }
754  return (object) $data;
755  }
756 }
setCreatedAt(?DateTimeImmutable $createdAt)
setCustomer(?CustomerReference $customer)
setUniquenessValue(?string $uniquenessValue)
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?string $uniquenessValue=null, ?string $locale=null, ?string $authorName=null, ?string $title=null, ?string $text=null, ?JsonObject $target=null, ?bool $includedInStatistics=null, ?int $rating=null, ?StateReference $state=null, ?CustomerReference $customer=null, ?CustomFields $custom=null)
setLastModifiedBy(?LastModifiedBy $lastModifiedBy)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
setIncludedInStatistics(?bool $includedInStatistics)