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