commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductSelectionModel.php
1<?php
2
3declare(strict_types=1);
10
25use DateTimeImmutable;
26use stdClass;
27
32{
37 protected $id;
38
43 protected $version;
44
49 protected $createdAt;
50
55 protected $lastModifiedAt;
56
61 protected $lastModifiedBy;
62
67 protected $createdBy;
68
73 protected $key;
74
79 protected $name;
80
85 protected $productCount;
86
91 protected $mode;
92
97 protected $custom;
98
99
103 public function __construct(
104 ?string $id = null,
105 ?int $version = null,
106 ?DateTimeImmutable $createdAt = null,
107 ?DateTimeImmutable $lastModifiedAt = null,
109 ?CreatedBy $createdBy = null,
110 ?string $key = null,
111 ?LocalizedString $name = null,
112 ?int $productCount = null,
113 ?string $mode = null,
114 ?CustomFields $custom = null
115 ) {
116 $this->id = $id;
117 $this->version = $version;
118 $this->createdAt = $createdAt;
119 $this->lastModifiedAt = $lastModifiedAt;
120 $this->lastModifiedBy = $lastModifiedBy;
121 $this->createdBy = $createdBy;
122 $this->key = $key;
123 $this->name = $name;
124 $this->productCount = $productCount;
125 $this->mode = $mode;
126 $this->custom = $custom;
127 }
128
135 public function getId()
136 {
137 if (is_null($this->id)) {
139 $data = $this->raw(self::FIELD_ID);
140 if (is_null($data)) {
141 return null;
142 }
143 $this->id = (string) $data;
144 }
145
146 return $this->id;
147 }
148
155 public function getVersion()
156 {
157 if (is_null($this->version)) {
159 $data = $this->raw(self::FIELD_VERSION);
160 if (is_null($data)) {
161 return null;
162 }
163 $this->version = (int) $data;
164 }
165
166 return $this->version;
167 }
168
175 public function getCreatedAt()
176 {
177 if (is_null($this->createdAt)) {
179 $data = $this->raw(self::FIELD_CREATED_AT);
180 if (is_null($data)) {
181 return null;
182 }
183 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
184 if (false === $data) {
185 return null;
186 }
187 $this->createdAt = $data;
188 }
189
190 return $this->createdAt;
191 }
192
199 public function getLastModifiedAt()
200 {
201 if (is_null($this->lastModifiedAt)) {
203 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
204 if (is_null($data)) {
205 return null;
206 }
207 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
208 if (false === $data) {
209 return null;
210 }
211 $this->lastModifiedAt = $data;
212 }
213
215 }
216
223 public function getLastModifiedBy()
224 {
225 if (is_null($this->lastModifiedBy)) {
227 $data = $this->raw(self::FIELD_LAST_MODIFIED_BY);
228 if (is_null($data)) {
229 return null;
230 }
231
232 $this->lastModifiedBy = LastModifiedByModel::of($data);
233 }
234
236 }
237
244 public function getCreatedBy()
245 {
246 if (is_null($this->createdBy)) {
248 $data = $this->raw(self::FIELD_CREATED_BY);
249 if (is_null($data)) {
250 return null;
251 }
252
253 $this->createdBy = CreatedByModel::of($data);
254 }
255
256 return $this->createdBy;
257 }
258
265 public function getKey()
266 {
267 if (is_null($this->key)) {
269 $data = $this->raw(self::FIELD_KEY);
270 if (is_null($data)) {
271 return null;
272 }
273 $this->key = (string) $data;
274 }
275
276 return $this->key;
277 }
278
285 public function getName()
286 {
287 if (is_null($this->name)) {
289 $data = $this->raw(self::FIELD_NAME);
290 if (is_null($data)) {
291 return null;
292 }
293
294 $this->name = LocalizedStringModel::of($data);
295 }
296
297 return $this->name;
298 }
299
306 public function getProductCount()
307 {
308 if (is_null($this->productCount)) {
310 $data = $this->raw(self::FIELD_PRODUCT_COUNT);
311 if (is_null($data)) {
312 return null;
313 }
314 $this->productCount = (int) $data;
315 }
316
317 return $this->productCount;
318 }
319
327 public function getMode()
328 {
329 if (is_null($this->mode)) {
331 $data = $this->raw(self::FIELD_MODE);
332 if (is_null($data)) {
333 return null;
334 }
335 $this->mode = (string) $data;
336 }
337
338 return $this->mode;
339 }
340
347 public function getCustom()
348 {
349 if (is_null($this->custom)) {
351 $data = $this->raw(self::FIELD_CUSTOM);
352 if (is_null($data)) {
353 return null;
354 }
355
356 $this->custom = CustomFieldsModel::of($data);
357 }
358
359 return $this->custom;
360 }
361
362
366 public function setId(?string $id): void
367 {
368 $this->id = $id;
369 }
370
374 public function setVersion(?int $version): void
375 {
376 $this->version = $version;
377 }
378
382 public function setCreatedAt(?DateTimeImmutable $createdAt): void
383 {
384 $this->createdAt = $createdAt;
385 }
386
390 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
391 {
392 $this->lastModifiedAt = $lastModifiedAt;
393 }
394
399 {
400 $this->lastModifiedBy = $lastModifiedBy;
401 }
402
406 public function setCreatedBy(?CreatedBy $createdBy): void
407 {
408 $this->createdBy = $createdBy;
409 }
410
414 public function setKey(?string $key): void
415 {
416 $this->key = $key;
417 }
418
422 public function setName(?LocalizedString $name): void
423 {
424 $this->name = $name;
425 }
426
430 public function setProductCount(?int $productCount): void
431 {
432 $this->productCount = $productCount;
433 }
434
438 public function setMode(?string $mode): void
439 {
440 $this->mode = $mode;
441 }
442
446 public function setCustom(?CustomFields $custom): void
447 {
448 $this->custom = $custom;
449 }
450
451
452 #[\ReturnTypeWillChange]
453 public function jsonSerialize()
454 {
455 $data = $this->toArray();
456 if (isset($data[ProductSelection::FIELD_CREATED_AT]) && $data[ProductSelection::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
457 $data[ProductSelection::FIELD_CREATED_AT] = $data[ProductSelection::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
458 }
459
460 if (isset($data[ProductSelection::FIELD_LAST_MODIFIED_AT]) && $data[ProductSelection::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
461 $data[ProductSelection::FIELD_LAST_MODIFIED_AT] = $data[ProductSelection::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
462 }
463 return (object) $data;
464 }
465}
__construct(?string $id=null, ?int $version=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?LastModifiedBy $lastModifiedBy=null, ?CreatedBy $createdBy=null, ?string $key=null, ?LocalizedString $name=null, ?int $productCount=null, ?string $mode=null, ?CustomFields $custom=null)