commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
VariantDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
21use stdClass;
22
26final class VariantDraftBuilder implements Builder
27{
32 private $key;
33
38 private $sku;
39
44 private $product;
45
50 private $publish;
51
56 private $images;
57
62 private $attributes;
63
68 private $assets;
69
77 public function getKey()
78 {
79 return $this->key;
80 }
81
88 public function getSku()
89 {
90 return $this->sku;
91 }
92
99 public function getProduct()
100 {
101 return $this->product instanceof ProductResourceIdentifierBuilder ? $this->product->build() : $this->product;
102 }
103
111 public function getPublish()
112 {
113 return $this->publish;
114 }
115
122 public function getImages()
123 {
124 return $this->images;
125 }
126
133 public function getAttributes()
134 {
135 return $this->attributes;
136 }
137
144 public function getAssets()
145 {
146 return $this->assets;
147 }
148
153 public function withKey(?string $key)
154 {
155 $this->key = $key;
156
157 return $this;
158 }
159
164 public function withSku(?string $sku)
165 {
166 $this->sku = $sku;
167
168 return $this;
169 }
170
175 public function withProduct(?ProductResourceIdentifier $product)
176 {
177 $this->product = $product;
178
179 return $this;
180 }
181
186 public function withPublish(?bool $publish)
187 {
188 $this->publish = $publish;
189
190 return $this;
191 }
192
197 public function withImages(?ImageCollection $images)
198 {
199 $this->images = $images;
200
201 return $this;
202 }
203
208 public function withAttributes(?AttributeCollection $attributes)
209 {
210 $this->attributes = $attributes;
211
212 return $this;
213 }
214
219 public function withAssets(?AssetDraftCollection $assets)
220 {
221 $this->assets = $assets;
222
223 return $this;
224 }
225
231 {
232 $this->product = $product;
233
234 return $this;
235 }
236
237 public function build(): VariantDraft
238 {
239 return new VariantDraftModel(
240 $this->key,
241 $this->sku,
242 $this->product instanceof ProductResourceIdentifierBuilder ? $this->product->build() : $this->product,
243 $this->publish,
244 $this->images,
245 $this->attributes,
246 $this->assets
247 );
248 }
249
250 public static function of(): VariantDraftBuilder
251 {
252 return new self();
253 }
254}
withProductBuilder(?ProductResourceIdentifierBuilder $product)