commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
AssignedProductReferenceBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
24 {
29  private $product;
30 
35  private $variantSelection;
36 
41  private $variantExclusion;
42 
49  public function getProduct()
50  {
51  return $this->product instanceof ProductReferenceBuilder ? $this->product->build() : $this->product;
52  }
53 
62  public function getVariantSelection()
63  {
64  return $this->variantSelection instanceof ProductVariantSelectionBuilder ? $this->variantSelection->build() : $this->variantSelection;
65  }
66 
75  public function getVariantExclusion()
76  {
77  return $this->variantExclusion instanceof ProductVariantExclusionBuilder ? $this->variantExclusion->build() : $this->variantExclusion;
78  }
79 
84  public function withProduct(?ProductReference $product)
85  {
86  $this->product = $product;
87 
88  return $this;
89  }
90 
95  public function withVariantSelection(?ProductVariantSelection $variantSelection)
96  {
97  $this->variantSelection = $variantSelection;
98 
99  return $this;
100  }
101 
106  public function withVariantExclusion(?ProductVariantExclusion $variantExclusion)
107  {
108  $this->variantExclusion = $variantExclusion;
109 
110  return $this;
111  }
112 
117  public function withProductBuilder(?ProductReferenceBuilder $product)
118  {
119  $this->product = $product;
120 
121  return $this;
122  }
123 
129  {
130  $this->variantSelection = $variantSelection;
131 
132  return $this;
133  }
134 
140  {
141  $this->variantExclusion = $variantExclusion;
142 
143  return $this;
144  }
145 
146  public function build(): AssignedProductReference
147  {
149  $this->product instanceof ProductReferenceBuilder ? $this->product->build() : $this->product,
150  $this->variantSelection instanceof ProductVariantSelectionBuilder ? $this->variantSelection->build() : $this->variantSelection,
151  $this->variantExclusion instanceof ProductVariantExclusionBuilder ? $this->variantExclusion->build() : $this->variantExclusion
152  );
153  }
154 
155  public static function of(): AssignedProductReferenceBuilder
156  {
157  return new self();
158  }
159 }