commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ProductVariantBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
23 use stdClass;
24 
28 final class ProductVariantBuilder implements Builder
29 {
34  private $id;
35 
40  private $sku;
41 
46  private $key;
47 
52  private $prices;
53 
58  private $attributes;
59 
64  private $price;
65 
70  private $images;
71 
76  private $assets;
77 
82  private $availability;
83 
88  private $isMatchingVariant;
89 
94  private $scopedPrice;
95 
100  private $scopedPriceDiscounted;
101 
108  public function getId()
109  {
110  return $this->id;
111  }
112 
119  public function getSku()
120  {
121  return $this->sku;
122  }
123 
131  public function getKey()
132  {
133  return $this->key;
134  }
135 
143  public function getPrices()
144  {
145  return $this->prices;
146  }
147 
154  public function getAttributes()
155  {
156  return $this->attributes;
157  }
158 
166  public function getPrice()
167  {
168  return $this->price instanceof PriceBuilder ? $this->price->build() : $this->price;
169  }
170 
177  public function getImages()
178  {
179  return $this->images;
180  }
181 
188  public function getAssets()
189  {
190  return $this->assets;
191  }
192 
201  public function getAvailability()
202  {
203  return $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability;
204  }
205 
213  public function getIsMatchingVariant()
214  {
215  return $this->isMatchingVariant;
216  }
217 
226  public function getScopedPrice()
227  {
228  return $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice;
229  }
230 
238  public function getScopedPriceDiscounted()
239  {
240  return $this->scopedPriceDiscounted;
241  }
242 
247  public function withId(?int $id)
248  {
249  $this->id = $id;
250 
251  return $this;
252  }
253 
258  public function withSku(?string $sku)
259  {
260  $this->sku = $sku;
261 
262  return $this;
263  }
264 
269  public function withKey(?string $key)
270  {
271  $this->key = $key;
272 
273  return $this;
274  }
275 
280  public function withPrices(?PriceCollection $prices)
281  {
282  $this->prices = $prices;
283 
284  return $this;
285  }
286 
291  public function withAttributes(?AttributeCollection $attributes)
292  {
293  $this->attributes = $attributes;
294 
295  return $this;
296  }
297 
302  public function withPrice(?Price $price)
303  {
304  $this->price = $price;
305 
306  return $this;
307  }
308 
313  public function withImages(?ImageCollection $images)
314  {
315  $this->images = $images;
316 
317  return $this;
318  }
319 
324  public function withAssets(?AssetCollection $assets)
325  {
326  $this->assets = $assets;
327 
328  return $this;
329  }
330 
335  public function withAvailability(?ProductVariantAvailability $availability)
336  {
337  $this->availability = $availability;
338 
339  return $this;
340  }
341 
346  public function withIsMatchingVariant(?bool $isMatchingVariant)
347  {
348  $this->isMatchingVariant = $isMatchingVariant;
349 
350  return $this;
351  }
352 
357  public function withScopedPrice(?ScopedPrice $scopedPrice)
358  {
359  $this->scopedPrice = $scopedPrice;
360 
361  return $this;
362  }
363 
368  public function withScopedPriceDiscounted(?bool $scopedPriceDiscounted)
369  {
370  $this->scopedPriceDiscounted = $scopedPriceDiscounted;
371 
372  return $this;
373  }
374 
379  public function withPriceBuilder(?PriceBuilder $price)
380  {
381  $this->price = $price;
382 
383  return $this;
384  }
385 
391  {
392  $this->availability = $availability;
393 
394  return $this;
395  }
396 
401  public function withScopedPriceBuilder(?ScopedPriceBuilder $scopedPrice)
402  {
403  $this->scopedPrice = $scopedPrice;
404 
405  return $this;
406  }
407 
408  public function build(): ProductVariant
409  {
410  return new ProductVariantModel(
411  $this->id,
412  $this->sku,
413  $this->key,
414  $this->prices,
415  $this->attributes,
416  $this->price instanceof PriceBuilder ? $this->price->build() : $this->price,
417  $this->images,
418  $this->assets,
419  $this->availability instanceof ProductVariantAvailabilityBuilder ? $this->availability->build() : $this->availability,
420  $this->isMatchingVariant,
421  $this->scopedPrice instanceof ScopedPriceBuilder ? $this->scopedPrice->build() : $this->scopedPrice,
422  $this->scopedPriceDiscounted
423  );
424  }
425 
426  public static function of(): ProductVariantBuilder
427  {
428  return new self();
429  }
430 }
withAvailabilityBuilder(?ProductVariantAvailabilityBuilder $availability)
withAvailability(?ProductVariantAvailability $availability)