commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductBuilder.php
1<?php
2
3declare(strict_types=1);
10
31use DateTimeImmutable;
32use stdClass;
33
37final class ProductBuilder implements Builder
38{
43 private $id;
44
49 private $version;
50
55 private $createdAt;
56
61 private $lastModifiedAt;
62
67 private $lastModifiedBy;
68
73 private $createdBy;
74
79 private $key;
80
85 private $productType;
86
91 private $masterData;
92
97 private $taxCategory;
98
103 private $state;
104
109 private $reviewRatingStatistics;
110
115 private $priceMode;
116
121 private $warnings;
122
129 public function getId()
130 {
131 return $this->id;
132 }
133
140 public function getVersion()
141 {
142 return $this->version;
143 }
144
151 public function getCreatedAt()
152 {
153 return $this->createdAt;
154 }
155
162 public function getLastModifiedAt()
163 {
164 return $this->lastModifiedAt;
165 }
166
173 public function getLastModifiedBy()
174 {
175 return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy;
176 }
177
184 public function getCreatedBy()
185 {
186 return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy;
187 }
188
196 public function getKey()
197 {
198 return $this->key;
199 }
200
207 public function getProductType()
208 {
209 return $this->productType instanceof ProductTypeReferenceBuilder ? $this->productType->build() : $this->productType;
210 }
211
218 public function getMasterData()
219 {
220 return $this->masterData instanceof ProductCatalogDataBuilder ? $this->masterData->build() : $this->masterData;
221 }
222
229 public function getTaxCategory()
230 {
231 return $this->taxCategory instanceof TaxCategoryReferenceBuilder ? $this->taxCategory->build() : $this->taxCategory;
232 }
233
240 public function getState()
241 {
242 return $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state;
243 }
244
252 {
253 return $this->reviewRatingStatistics instanceof ReviewRatingStatisticsBuilder ? $this->reviewRatingStatistics->build() : $this->reviewRatingStatistics;
254 }
255
262 public function getPriceMode()
263 {
264 return $this->priceMode;
265 }
266
274 public function getWarnings()
275 {
276 return $this->warnings;
277 }
278
283 public function withId(?string $id)
284 {
285 $this->id = $id;
286
287 return $this;
288 }
289
294 public function withVersion(?int $version)
295 {
296 $this->version = $version;
297
298 return $this;
299 }
300
305 public function withCreatedAt(?DateTimeImmutable $createdAt)
306 {
307 $this->createdAt = $createdAt;
308
309 return $this;
310 }
311
316 public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
317 {
318 $this->lastModifiedAt = $lastModifiedAt;
319
320 return $this;
321 }
322
327 public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
328 {
329 $this->lastModifiedBy = $lastModifiedBy;
330
331 return $this;
332 }
333
338 public function withCreatedBy(?CreatedBy $createdBy)
339 {
340 $this->createdBy = $createdBy;
341
342 return $this;
343 }
344
349 public function withKey(?string $key)
350 {
351 $this->key = $key;
352
353 return $this;
354 }
355
360 public function withProductType(?ProductTypeReference $productType)
361 {
362 $this->productType = $productType;
363
364 return $this;
365 }
366
371 public function withMasterData(?ProductCatalogData $masterData)
372 {
373 $this->masterData = $masterData;
374
375 return $this;
376 }
377
382 public function withTaxCategory(?TaxCategoryReference $taxCategory)
383 {
384 $this->taxCategory = $taxCategory;
385
386 return $this;
387 }
388
393 public function withState(?StateReference $state)
394 {
395 $this->state = $state;
396
397 return $this;
398 }
399
404 public function withReviewRatingStatistics(?ReviewRatingStatistics $reviewRatingStatistics)
405 {
406 $this->reviewRatingStatistics = $reviewRatingStatistics;
407
408 return $this;
409 }
410
415 public function withPriceMode(?string $priceMode)
416 {
417 $this->priceMode = $priceMode;
418
419 return $this;
420 }
421
426 public function withWarnings(?WarningObjectCollection $warnings)
427 {
428 $this->warnings = $warnings;
429
430 return $this;
431 }
432
437 public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
438 {
439 $this->lastModifiedBy = $lastModifiedBy;
440
441 return $this;
442 }
443
448 public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
449 {
450 $this->createdBy = $createdBy;
451
452 return $this;
453 }
454
460 {
461 $this->productType = $productType;
462
463 return $this;
464 }
465
471 {
472 $this->masterData = $masterData;
473
474 return $this;
475 }
476
482 {
483 $this->taxCategory = $taxCategory;
484
485 return $this;
486 }
487
493 {
494 $this->state = $state;
495
496 return $this;
497 }
498
503 public function withReviewRatingStatisticsBuilder(?ReviewRatingStatisticsBuilder $reviewRatingStatistics)
504 {
505 $this->reviewRatingStatistics = $reviewRatingStatistics;
506
507 return $this;
508 }
509
510 public function build(): Product
511 {
512 return new ProductModel(
513 $this->id,
514 $this->version,
515 $this->createdAt,
516 $this->lastModifiedAt,
517 $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
518 $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy,
519 $this->key,
520 $this->productType instanceof ProductTypeReferenceBuilder ? $this->productType->build() : $this->productType,
521 $this->masterData instanceof ProductCatalogDataBuilder ? $this->masterData->build() : $this->masterData,
522 $this->taxCategory instanceof TaxCategoryReferenceBuilder ? $this->taxCategory->build() : $this->taxCategory,
523 $this->state instanceof StateReferenceBuilder ? $this->state->build() : $this->state,
524 $this->reviewRatingStatistics instanceof ReviewRatingStatisticsBuilder ? $this->reviewRatingStatistics->build() : $this->reviewRatingStatistics,
525 $this->priceMode,
526 $this->warnings
527 );
528 }
529
530 public static function of(): ProductBuilder
531 {
532 return new self();
533 }
534}
withProductTypeBuilder(?ProductTypeReferenceBuilder $productType)
withWarnings(?WarningObjectCollection $warnings)
withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
withTaxCategory(?TaxCategoryReference $taxCategory)
withMasterDataBuilder(?ProductCatalogDataBuilder $masterData)
withTaxCategoryBuilder(?TaxCategoryReferenceBuilder $taxCategory)
withReviewRatingStatistics(?ReviewRatingStatistics $reviewRatingStatistics)
withStateBuilder(?StateReferenceBuilder $state)
withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
withProductType(?ProductTypeReference $productType)
withCreatedByBuilder(?CreatedByBuilder $createdBy)
withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
withReviewRatingStatisticsBuilder(?ReviewRatingStatisticsBuilder $reviewRatingStatistics)
withMasterData(?ProductCatalogData $masterData)