commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
ReferenceAttributeBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class ReferenceAttributeBuilder implements Builder
24 {
29  private $name;
30 
35  private $value;
36 
45  public function getName()
46  {
47  return $this->name;
48  }
49 
56  public function getValue()
57  {
58  return $this->value instanceof KeyReferenceBuilder ? $this->value->build() : $this->value;
59  }
60 
65  public function withName(?string $name)
66  {
67  $this->name = $name;
68 
69  return $this;
70  }
71 
76  public function withValue(?KeyReference $value)
77  {
78  $this->value = $value;
79 
80  return $this;
81  }
82 
87  public function withValueBuilder(?KeyReferenceBuilder $value)
88  {
89  $this->value = $value;
90 
91  return $this;
92  }
93 
94  public function build(): ReferenceAttribute
95  {
96  return new ReferenceAttributeModel(
97  $this->name,
98  $this->value instanceof KeyReferenceBuilder ? $this->value->build() : $this->value
99  );
100  }
101 
102  public static function of(): ReferenceAttributeBuilder
103  {
104  return new self();
105  }
106 }