commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
OrderEditAppliedModel.php
1<?php
2
3declare(strict_types=1);
10
15use DateTimeImmutable;
16use stdClass;
17
22{
23 public const DISCRIMINATOR_VALUE = 'Applied';
28 protected $type;
29
34 protected $appliedAt;
35
41
47
48
52 public function __construct(
53 ?DateTimeImmutable $appliedAt = null,
56 ?string $type = null
57 ) {
58 $this->appliedAt = $appliedAt;
59 $this->excerptBeforeEdit = $excerptBeforeEdit;
60 $this->excerptAfterEdit = $excerptAfterEdit;
61 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
62 }
63
70 public function getType()
71 {
72 if (is_null($this->type)) {
74 $data = $this->raw(self::FIELD_TYPE);
75 if (is_null($data)) {
76 return null;
77 }
78 $this->type = (string) $data;
79 }
80
81 return $this->type;
82 }
83
90 public function getAppliedAt()
91 {
92 if (is_null($this->appliedAt)) {
94 $data = $this->raw(self::FIELD_APPLIED_AT);
95 if (is_null($data)) {
96 return null;
97 }
98 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
99 if (false === $data) {
100 return null;
101 }
102 $this->appliedAt = $data;
103 }
104
105 return $this->appliedAt;
106 }
107
114 public function getExcerptBeforeEdit()
115 {
116 if (is_null($this->excerptBeforeEdit)) {
118 $data = $this->raw(self::FIELD_EXCERPT_BEFORE_EDIT);
119 if (is_null($data)) {
120 return null;
121 }
122
123 $this->excerptBeforeEdit = OrderExcerptModel::of($data);
124 }
125
127 }
128
135 public function getExcerptAfterEdit()
136 {
137 if (is_null($this->excerptAfterEdit)) {
139 $data = $this->raw(self::FIELD_EXCERPT_AFTER_EDIT);
140 if (is_null($data)) {
141 return null;
142 }
143
144 $this->excerptAfterEdit = OrderExcerptModel::of($data);
145 }
146
148 }
149
150
154 public function setAppliedAt(?DateTimeImmutable $appliedAt): void
155 {
156 $this->appliedAt = $appliedAt;
157 }
158
163 {
164 $this->excerptBeforeEdit = $excerptBeforeEdit;
165 }
166
171 {
172 $this->excerptAfterEdit = $excerptAfterEdit;
173 }
174
175
176 #[\ReturnTypeWillChange]
177 public function jsonSerialize()
178 {
179 $data = $this->toArray();
180 if (isset($data[OrderEditApplied::FIELD_APPLIED_AT]) && $data[OrderEditApplied::FIELD_APPLIED_AT] instanceof \DateTimeImmutable) {
181 $data[OrderEditApplied::FIELD_APPLIED_AT] = $data[OrderEditApplied::FIELD_APPLIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
182 }
183 return (object) $data;
184 }
185}
__construct(?DateTimeImmutable $appliedAt=null, ?OrderExcerpt $excerptBeforeEdit=null, ?OrderExcerpt $excerptAfterEdit=null, ?string $type=null)