commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DiscountedPriceDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class DiscountedPriceDraftBuilder implements Builder
24 {
29  private $value;
30 
35  private $discount;
36 
43  public function getValue()
44  {
45  return $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value;
46  }
47 
54  public function getDiscount()
55  {
56  return $this->discount instanceof ProductDiscountReferenceBuilder ? $this->discount->build() : $this->discount;
57  }
58 
63  public function withValue(?Money $value)
64  {
65  $this->value = $value;
66 
67  return $this;
68  }
69 
74  public function withDiscount(?ProductDiscountReference $discount)
75  {
76  $this->discount = $discount;
77 
78  return $this;
79  }
80 
85  public function withValueBuilder(?MoneyBuilder $value)
86  {
87  $this->value = $value;
88 
89  return $this;
90  }
91 
97  {
98  $this->discount = $discount;
99 
100  return $this;
101  }
102 
103  public function build(): DiscountedPriceDraft
104  {
105  return new DiscountedPriceDraftModel(
106  $this->value instanceof MoneyBuilder ? $this->value->build() : $this->value,
107  $this->discount instanceof ProductDiscountReferenceBuilder ? $this->discount->build() : $this->discount
108  );
109  }
110 
111  public static function of(): DiscountedPriceDraftBuilder
112  {
113  return new self();
114  }
115 }