commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
TaxPortionBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class TaxPortionBuilder implements Builder
24 {
29  private $name;
30 
35  private $rate;
36 
41  private $amount;
42 
47  public function getName()
48  {
49  return $this->name;
50  }
51 
56  public function getRate()
57  {
58  return $this->rate;
59  }
60 
65  public function getAmount()
66  {
67  return $this->amount instanceof TypedMoneyBuilder ? $this->amount->build() : $this->amount;
68  }
69 
74  public function withName(?string $name)
75  {
76  $this->name = $name;
77 
78  return $this;
79  }
80 
85  public function withRate(?float $rate)
86  {
87  $this->rate = $rate;
88 
89  return $this;
90  }
91 
96  public function withAmount(?TypedMoney $amount)
97  {
98  $this->amount = $amount;
99 
100  return $this;
101  }
102 
107  public function withAmountBuilder(?TypedMoneyBuilder $amount)
108  {
109  $this->amount = $amount;
110 
111  return $this;
112  }
113 
114  public function build(): TaxPortion
115  {
116  return new TaxPortionModel(
117  $this->name,
118  $this->rate,
119  $this->amount instanceof TypedMoneyBuilder ? $this->amount->build() : $this->amount
120  );
121  }
122 
123  public static function of(): TaxPortionBuilder
124  {
125  return new self();
126  }
127 }