commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
AttributeDefinitionBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class AttributeDefinitionBuilder implements Builder
24 {
29  private $type;
30 
35  private $name;
36 
41  private $label;
42 
47  private $isRequired;
48 
53  private $attributeConstraint;
54 
59  private $inputTip;
60 
65  private $inputHint;
66 
71  private $isSearchable;
72 
77  public function getType()
78  {
79  return $this->type instanceof AttributeTypeBuilder ? $this->type->build() : $this->type;
80  }
81 
86  public function getName()
87  {
88  return $this->name;
89  }
90 
102  public function getLabel()
103  {
104  return $this->label instanceof LocalizedStringBuilder ? $this->label->build() : $this->label;
105  }
106 
111  public function getIsRequired()
112  {
113  return $this->isRequired;
114  }
115 
120  public function getAttributeConstraint()
121  {
122  return $this->attributeConstraint;
123  }
124 
136  public function getInputTip()
137  {
138  return $this->inputTip instanceof LocalizedStringBuilder ? $this->inputTip->build() : $this->inputTip;
139  }
140 
145  public function getInputHint()
146  {
147  return $this->inputHint;
148  }
149 
154  public function getIsSearchable()
155  {
156  return $this->isSearchable;
157  }
158 
163  public function withType(?AttributeType $type)
164  {
165  $this->type = $type;
166 
167  return $this;
168  }
169 
174  public function withName(?string $name)
175  {
176  $this->name = $name;
177 
178  return $this;
179  }
180 
185  public function withLabel(?LocalizedString $label)
186  {
187  $this->label = $label;
188 
189  return $this;
190  }
191 
196  public function withIsRequired(?bool $isRequired)
197  {
198  $this->isRequired = $isRequired;
199 
200  return $this;
201  }
202 
207  public function withAttributeConstraint(?string $attributeConstraint)
208  {
209  $this->attributeConstraint = $attributeConstraint;
210 
211  return $this;
212  }
213 
218  public function withInputTip(?LocalizedString $inputTip)
219  {
220  $this->inputTip = $inputTip;
221 
222  return $this;
223  }
224 
229  public function withInputHint(?string $inputHint)
230  {
231  $this->inputHint = $inputHint;
232 
233  return $this;
234  }
235 
240  public function withIsSearchable(?bool $isSearchable)
241  {
242  $this->isSearchable = $isSearchable;
243 
244  return $this;
245  }
246 
251  public function withTypeBuilder(?AttributeTypeBuilder $type)
252  {
253  $this->type = $type;
254 
255  return $this;
256  }
257 
262  public function withLabelBuilder(?LocalizedStringBuilder $label)
263  {
264  $this->label = $label;
265 
266  return $this;
267  }
268 
273  public function withInputTipBuilder(?LocalizedStringBuilder $inputTip)
274  {
275  $this->inputTip = $inputTip;
276 
277  return $this;
278  }
279 
280  public function build(): AttributeDefinition
281  {
282  return new AttributeDefinitionModel(
283  $this->type instanceof AttributeTypeBuilder ? $this->type->build() : $this->type,
284  $this->name,
285  $this->label instanceof LocalizedStringBuilder ? $this->label->build() : $this->label,
286  $this->isRequired,
287  $this->attributeConstraint,
288  $this->inputTip instanceof LocalizedStringBuilder ? $this->inputTip->build() : $this->inputTip,
289  $this->inputHint,
290  $this->isSearchable
291  );
292  }
293 
294  public static function of(): AttributeDefinitionBuilder
295  {
296  return new self();
297  }
298 }