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