commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductDataBuilder.php
1<?php
2
3declare(strict_types=1);
10
19use stdClass;
20
24final class ProductDataBuilder implements Builder
25{
30 private $name;
31
36 private $categories;
37
42 private $categoryOrderHints;
43
48 private $description;
49
54 private $slug;
55
60 private $metaTitle;
61
66 private $metaDescription;
67
72 private $metaKeywords;
73
78 private $masterVariant;
79
84 private $variants;
85
90 private $searchKeywords;
91
96 private $attributes;
97
104 public function getName()
105 {
106 return $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name;
107 }
108
115 public function getCategories()
116 {
117 return $this->categories;
118 }
119
126 public function getCategoryOrderHints()
127 {
128 return $this->categoryOrderHints instanceof CategoryOrderHintsBuilder ? $this->categoryOrderHints->build() : $this->categoryOrderHints;
129 }
130
137 public function getDescription()
138 {
139 return $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description;
140 }
141
150 public function getSlug()
151 {
152 return $this->slug instanceof LocalizedStringBuilder ? $this->slug->build() : $this->slug;
153 }
154
161 public function getMetaTitle()
162 {
163 return $this->metaTitle instanceof LocalizedStringBuilder ? $this->metaTitle->build() : $this->metaTitle;
164 }
165
172 public function getMetaDescription()
173 {
174 return $this->metaDescription instanceof LocalizedStringBuilder ? $this->metaDescription->build() : $this->metaDescription;
175 }
176
183 public function getMetaKeywords()
184 {
185 return $this->metaKeywords instanceof LocalizedStringBuilder ? $this->metaKeywords->build() : $this->metaKeywords;
186 }
187
194 public function getMasterVariant()
195 {
196 return $this->masterVariant instanceof ProductVariantBuilder ? $this->masterVariant->build() : $this->masterVariant;
197 }
198
205 public function getVariants()
206 {
207 return $this->variants;
208 }
209
216 public function getSearchKeywords()
217 {
218 return $this->searchKeywords instanceof SearchKeywordsBuilder ? $this->searchKeywords->build() : $this->searchKeywords;
219 }
220
228 public function getAttributes()
229 {
230 return $this->attributes;
231 }
232
237 public function withName(?LocalizedString $name)
238 {
239 $this->name = $name;
240
241 return $this;
242 }
243
248 public function withCategories(?CategoryReferenceCollection $categories)
249 {
250 $this->categories = $categories;
251
252 return $this;
253 }
254
259 public function withCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
260 {
261 $this->categoryOrderHints = $categoryOrderHints;
262
263 return $this;
264 }
265
270 public function withDescription(?LocalizedString $description)
271 {
272 $this->description = $description;
273
274 return $this;
275 }
276
281 public function withSlug(?LocalizedString $slug)
282 {
283 $this->slug = $slug;
284
285 return $this;
286 }
287
292 public function withMetaTitle(?LocalizedString $metaTitle)
293 {
294 $this->metaTitle = $metaTitle;
295
296 return $this;
297 }
298
303 public function withMetaDescription(?LocalizedString $metaDescription)
304 {
305 $this->metaDescription = $metaDescription;
306
307 return $this;
308 }
309
314 public function withMetaKeywords(?LocalizedString $metaKeywords)
315 {
316 $this->metaKeywords = $metaKeywords;
317
318 return $this;
319 }
320
325 public function withMasterVariant(?ProductVariant $masterVariant)
326 {
327 $this->masterVariant = $masterVariant;
328
329 return $this;
330 }
331
336 public function withVariants(?ProductVariantCollection $variants)
337 {
338 $this->variants = $variants;
339
340 return $this;
341 }
342
347 public function withSearchKeywords(?SearchKeywords $searchKeywords)
348 {
349 $this->searchKeywords = $searchKeywords;
350
351 return $this;
352 }
353
358 public function withAttributes(?AttributeCollection $attributes)
359 {
360 $this->attributes = $attributes;
361
362 return $this;
363 }
364
370 {
371 $this->name = $name;
372
373 return $this;
374 }
375
380 public function withCategoryOrderHintsBuilder(?CategoryOrderHintsBuilder $categoryOrderHints)
381 {
382 $this->categoryOrderHints = $categoryOrderHints;
383
384 return $this;
385 }
386
391 public function withDescriptionBuilder(?LocalizedStringBuilder $description)
392 {
393 $this->description = $description;
394
395 return $this;
396 }
397
403 {
404 $this->slug = $slug;
405
406 return $this;
407 }
408
413 public function withMetaTitleBuilder(?LocalizedStringBuilder $metaTitle)
414 {
415 $this->metaTitle = $metaTitle;
416
417 return $this;
418 }
419
424 public function withMetaDescriptionBuilder(?LocalizedStringBuilder $metaDescription)
425 {
426 $this->metaDescription = $metaDescription;
427
428 return $this;
429 }
430
435 public function withMetaKeywordsBuilder(?LocalizedStringBuilder $metaKeywords)
436 {
437 $this->metaKeywords = $metaKeywords;
438
439 return $this;
440 }
441
446 public function withMasterVariantBuilder(?ProductVariantBuilder $masterVariant)
447 {
448 $this->masterVariant = $masterVariant;
449
450 return $this;
451 }
452
457 public function withSearchKeywordsBuilder(?SearchKeywordsBuilder $searchKeywords)
458 {
459 $this->searchKeywords = $searchKeywords;
460
461 return $this;
462 }
463
464 public function build(): ProductData
465 {
466 return new ProductDataModel(
467 $this->name instanceof LocalizedStringBuilder ? $this->name->build() : $this->name,
468 $this->categories,
469 $this->categoryOrderHints instanceof CategoryOrderHintsBuilder ? $this->categoryOrderHints->build() : $this->categoryOrderHints,
470 $this->description instanceof LocalizedStringBuilder ? $this->description->build() : $this->description,
471 $this->slug instanceof LocalizedStringBuilder ? $this->slug->build() : $this->slug,
472 $this->metaTitle instanceof LocalizedStringBuilder ? $this->metaTitle->build() : $this->metaTitle,
473 $this->metaDescription instanceof LocalizedStringBuilder ? $this->metaDescription->build() : $this->metaDescription,
474 $this->metaKeywords instanceof LocalizedStringBuilder ? $this->metaKeywords->build() : $this->metaKeywords,
475 $this->masterVariant instanceof ProductVariantBuilder ? $this->masterVariant->build() : $this->masterVariant,
476 $this->variants,
477 $this->searchKeywords instanceof SearchKeywordsBuilder ? $this->searchKeywords->build() : $this->searchKeywords,
478 $this->attributes
479 );
480 }
481
482 public static function of(): ProductDataBuilder
483 {
484 return new self();
485 }
486}
withCategories(?CategoryReferenceCollection $categories)
withCategoryOrderHintsBuilder(?CategoryOrderHintsBuilder $categoryOrderHints)
withMasterVariantBuilder(?ProductVariantBuilder $masterVariant)
withVariants(?ProductVariantCollection $variants)
withDescriptionBuilder(?LocalizedStringBuilder $description)
withMetaDescription(?LocalizedString $metaDescription)
withSearchKeywordsBuilder(?SearchKeywordsBuilder $searchKeywords)
withMetaTitleBuilder(?LocalizedStringBuilder $metaTitle)
withCategoryOrderHints(?CategoryOrderHints $categoryOrderHints)
withMetaDescriptionBuilder(?LocalizedStringBuilder $metaDescription)
withMetaKeywordsBuilder(?LocalizedStringBuilder $metaKeywords)