commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ProductVariantPatchBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
20 use stdClass;
21 
25 final class ProductVariantPatchBuilder implements Builder
26 {
31  private $productVariant;
32 
37  private $attributes;
38 
43  private $staged;
44 
49  private $product;
50 
58  public function getProductVariant()
59  {
60  return $this->productVariant instanceof ProductVariantKeyReferenceBuilder ? $this->productVariant->build() : $this->productVariant;
61  }
62 
75  public function getAttributes()
76  {
77  return $this->attributes instanceof AttributesBuilder ? $this->attributes->build() : $this->attributes;
78  }
79 
86  public function getStaged()
87  {
88  return $this->staged;
89  }
90 
97  public function getProduct()
98  {
99  return $this->product instanceof ProductKeyReferenceBuilder ? $this->product->build() : $this->product;
100  }
101 
106  public function withProductVariant(?ProductVariantKeyReference $productVariant)
107  {
108  $this->productVariant = $productVariant;
109 
110  return $this;
111  }
112 
117  public function withAttributes(?Attributes $attributes)
118  {
119  $this->attributes = $attributes;
120 
121  return $this;
122  }
123 
128  public function withStaged(?bool $staged)
129  {
130  $this->staged = $staged;
131 
132  return $this;
133  }
134 
139  public function withProduct(?ProductKeyReference $product)
140  {
141  $this->product = $product;
142 
143  return $this;
144  }
145 
151  {
152  $this->productVariant = $productVariant;
153 
154  return $this;
155  }
156 
161  public function withAttributesBuilder(?AttributesBuilder $attributes)
162  {
163  $this->attributes = $attributes;
164 
165  return $this;
166  }
167 
173  {
174  $this->product = $product;
175 
176  return $this;
177  }
178 
179  public function build(): ProductVariantPatch
180  {
181  return new ProductVariantPatchModel(
182  $this->productVariant instanceof ProductVariantKeyReferenceBuilder ? $this->productVariant->build() : $this->productVariant,
183  $this->attributes instanceof AttributesBuilder ? $this->attributes->build() : $this->attributes,
184  $this->staged,
185  $this->product instanceof ProductKeyReferenceBuilder ? $this->product->build() : $this->product
186  );
187  }
188 
189  public static function of(): ProductVariantPatchBuilder
190  {
191  return new self();
192  }
193 }
withProductVariantBuilder(?ProductVariantKeyReferenceBuilder $productVariant)