commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
DiscountedPriceBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
16 use stdClass;
17 
21 final class DiscountedPriceBuilder implements Builder
22 {
27  private $value;
28 
33  private $discount;
34 
39  public function getValue()
40  {
41  return $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value;
42  }
43 
50  public function getDiscount()
51  {
52  return $this->discount instanceof ProductDiscountKeyReferenceBuilder ? $this->discount->build() : $this->discount;
53  }
54 
59  public function withValue(?TypedMoney $value)
60  {
61  $this->value = $value;
62 
63  return $this;
64  }
65 
70  public function withDiscount(?ProductDiscountKeyReference $discount)
71  {
72  $this->discount = $discount;
73 
74  return $this;
75  }
76 
81  public function withValueBuilder(?TypedMoneyBuilder $value)
82  {
83  $this->value = $value;
84 
85  return $this;
86  }
87 
93  {
94  $this->discount = $discount;
95 
96  return $this;
97  }
98 
99  public function build(): DiscountedPrice
100  {
101  return new DiscountedPriceModel(
102  $this->value instanceof TypedMoneyBuilder ? $this->value->build() : $this->value,
103  $this->discount instanceof ProductDiscountKeyReferenceBuilder ? $this->discount->build() : $this->discount
104  );
105  }
106 
107  public static function of(): DiscountedPriceBuilder
108  {
109  return new self();
110  }
111 }
withDiscountBuilder(?ProductDiscountKeyReferenceBuilder $discount)