commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CustomBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class CustomBuilder implements Builder
24 {
29  private $type;
30 
35  private $fields;
36 
43  public function getType()
44  {
45  return $this->type instanceof TypeKeyReferenceBuilder ? $this->type->build() : $this->type;
46  }
47 
54  public function getFields()
55  {
56  return $this->fields instanceof FieldContainerBuilder ? $this->fields->build() : $this->fields;
57  }
58 
63  public function withType(?TypeKeyReference $type)
64  {
65  $this->type = $type;
66 
67  return $this;
68  }
69 
74  public function withFields(?FieldContainer $fields)
75  {
76  $this->fields = $fields;
77 
78  return $this;
79  }
80 
85  public function withTypeBuilder(?TypeKeyReferenceBuilder $type)
86  {
87  $this->type = $type;
88 
89  return $this;
90  }
91 
96  public function withFieldsBuilder(?FieldContainerBuilder $fields)
97  {
98  $this->fields = $fields;
99 
100  return $this;
101  }
102 
103  public function build(): Custom
104  {
105  return new CustomModel(
106  $this->type instanceof TypeKeyReferenceBuilder ? $this->type->build() : $this->type,
107  $this->fields instanceof FieldContainerBuilder ? $this->fields->build() : $this->fields
108  );
109  }
110 
111  public static function of(): CustomBuilder
112  {
113  return new self();
114  }
115 }