commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
RecurrencePolicyModel.php
1<?php
2
3declare(strict_types=1);
10
23use DateTimeImmutable;
24use stdClass;
25
30{
35 protected $id;
36
41 protected $version;
42
47 protected $createdAt;
48
53 protected $lastModifiedAt;
54
59 protected $key;
60
65 protected $name;
66
71 protected $description;
72
77 protected $schedule;
78
83 protected $createdBy;
84
89 protected $lastModifiedBy;
90
91
95 public function __construct(
96 ?string $id = null,
97 ?int $version = null,
98 ?DateTimeImmutable $createdAt = null,
99 ?DateTimeImmutable $lastModifiedAt = null,
100 ?string $key = null,
101 ?LocalizedString $name = null,
104 ?CreatedBy $createdBy = null,
106 ) {
107 $this->id = $id;
108 $this->version = $version;
109 $this->createdAt = $createdAt;
110 $this->lastModifiedAt = $lastModifiedAt;
111 $this->key = $key;
112 $this->name = $name;
113 $this->description = $description;
114 $this->schedule = $schedule;
115 $this->createdBy = $createdBy;
116 $this->lastModifiedBy = $lastModifiedBy;
117 }
118
125 public function getId()
126 {
127 if (is_null($this->id)) {
129 $data = $this->raw(self::FIELD_ID);
130 if (is_null($data)) {
131 return null;
132 }
133 $this->id = (string) $data;
134 }
135
136 return $this->id;
137 }
138
145 public function getVersion()
146 {
147 if (is_null($this->version)) {
149 $data = $this->raw(self::FIELD_VERSION);
150 if (is_null($data)) {
151 return null;
152 }
153 $this->version = (int) $data;
154 }
155
156 return $this->version;
157 }
158
165 public function getCreatedAt()
166 {
167 if (is_null($this->createdAt)) {
169 $data = $this->raw(self::FIELD_CREATED_AT);
170 if (is_null($data)) {
171 return null;
172 }
173 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
174 if (false === $data) {
175 return null;
176 }
177 $this->createdAt = $data;
178 }
179
180 return $this->createdAt;
181 }
182
189 public function getLastModifiedAt()
190 {
191 if (is_null($this->lastModifiedAt)) {
193 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
194 if (is_null($data)) {
195 return null;
196 }
197 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
198 if (false === $data) {
199 return null;
200 }
201 $this->lastModifiedAt = $data;
202 }
203
205 }
206
213 public function getKey()
214 {
215 if (is_null($this->key)) {
217 $data = $this->raw(self::FIELD_KEY);
218 if (is_null($data)) {
219 return null;
220 }
221 $this->key = (string) $data;
222 }
223
224 return $this->key;
225 }
226
233 public function getName()
234 {
235 if (is_null($this->name)) {
237 $data = $this->raw(self::FIELD_NAME);
238 if (is_null($data)) {
239 return null;
240 }
241
242 $this->name = LocalizedStringModel::of($data);
243 }
244
245 return $this->name;
246 }
247
254 public function getDescription()
255 {
256 if (is_null($this->description)) {
258 $data = $this->raw(self::FIELD_DESCRIPTION);
259 if (is_null($data)) {
260 return null;
261 }
262
263 $this->description = LocalizedStringModel::of($data);
264 }
265
266 return $this->description;
267 }
268
275 public function getSchedule()
276 {
277 if (is_null($this->schedule)) {
279 $data = $this->raw(self::FIELD_SCHEDULE);
280 if (is_null($data)) {
281 return null;
282 }
284 $this->schedule = $className::of($data);
285 }
286
287 return $this->schedule;
288 }
289
296 public function getCreatedBy()
297 {
298 if (is_null($this->createdBy)) {
300 $data = $this->raw(self::FIELD_CREATED_BY);
301 if (is_null($data)) {
302 return null;
303 }
304
305 $this->createdBy = CreatedByModel::of($data);
306 }
307
308 return $this->createdBy;
309 }
310
317 public function getLastModifiedBy()
318 {
319 if (is_null($this->lastModifiedBy)) {
321 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
322 if (is_null($data)) {
323 return null;
324 }
325
326 $this->lastModifiedBy = LastModifiedByModel::of($data);
327 }
328
330 }
331
332
336 public function setId(?string $id): void
337 {
338 $this->id = $id;
339 }
340
344 public function setVersion(?int $version): void
345 {
346 $this->version = $version;
347 }
348
352 public function setCreatedAt(?DateTimeImmutable $createdAt): void
353 {
354 $this->createdAt = $createdAt;
355 }
356
360 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
361 {
362 $this->lastModifiedAt = $lastModifiedAt;
363 }
364
368 public function setKey(?string $key): void
369 {
370 $this->key = $key;
371 }
372
376 public function setName(?LocalizedString $name): void
377 {
378 $this->name = $name;
379 }
380
385 {
386 $this->description = $description;
387 }
388
393 {
394 $this->schedule = $schedule;
395 }
396
400 public function setCreatedBy(?CreatedBy $createdBy): void
401 {
402 $this->createdBy = $createdBy;
403 }
404
409 {
410 $this->lastModifiedBy = $lastModifiedBy;
411 }
412
413
414 #[\ReturnTypeWillChange]
415 public function jsonSerialize()
416 {
417 $data = $this->toArray();
418 if (isset($data[RecurrencePolicy::FIELD_CREATED_AT]) && $data[RecurrencePolicy::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
419 $data[RecurrencePolicy::FIELD_CREATED_AT] = $data[RecurrencePolicy::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
420 }
421
422 if (isset($data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT]) && $data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
423 $data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT] = $data[RecurrencePolicy::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
424 }
425 return (object) $data;
426 }
427}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?string $key=null, ?LocalizedString $name=null, ?LocalizedString $description=null, ?RecurrencePolicySchedule $schedule=null, ?CreatedBy $createdBy=null, ?LastModifiedBy $lastModifiedBy=null)