commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
RecurringOrderActiveModel.php
1<?php
2
3declare(strict_types=1);
10
15use DateTimeImmutable;
16use stdClass;
17
22{
23 public const DISCRIMINATOR_VALUE = 'active';
28 protected $type;
29
34 protected $resumesAt;
35
36
40 public function __construct(
41 ?DateTimeImmutable $resumesAt = null,
42 ?string $type = null
43 ) {
44 $this->resumesAt = $resumesAt;
45 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
46 }
47
52 public function getType()
53 {
54 if (is_null($this->type)) {
56 $data = $this->raw(self::FIELD_TYPE);
57 if (is_null($data)) {
58 return null;
59 }
60 $this->type = (string) $data;
61 }
62
63 return $this->type;
64 }
65
72 public function getResumesAt()
73 {
74 if (is_null($this->resumesAt)) {
76 $data = $this->raw(self::FIELD_RESUMES_AT);
77 if (is_null($data)) {
78 return null;
79 }
80 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
81 if (false === $data) {
82 return null;
83 }
84 $this->resumesAt = $data;
85 }
86
87 return $this->resumesAt;
88 }
89
90
94 public function setResumesAt(?DateTimeImmutable $resumesAt): void
95 {
96 $this->resumesAt = $resumesAt;
97 }
98
99
100 #[\ReturnTypeWillChange]
101 public function jsonSerialize()
102 {
103 $data = $this->toArray();
104 if (isset($data[RecurringOrderActive::FIELD_RESUMES_AT]) && $data[RecurringOrderActive::FIELD_RESUMES_AT] instanceof \DateTimeImmutable) {
105 $data[RecurringOrderActive::FIELD_RESUMES_AT] = $data[RecurringOrderActive::FIELD_RESUMES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
106 }
107 return (object) $data;
108 }
109}
__construct(?DateTimeImmutable $resumesAt=null, ?string $type=null)