commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DirectDiscountBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
20 use stdClass;
21 
25 final class DirectDiscountBuilder implements Builder
26 {
31  private $id;
32 
37  private $value;
38 
43  private $target;
44 
51  public function getId()
52  {
53  return $this->id;
54  }
55 
62  public function getValue()
63  {
64  return $this->value instanceof CartDiscountValueBuilder ? $this->value->build() : $this->value;
65  }
66 
74  public function getTarget()
75  {
76  return $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target;
77  }
78 
83  public function withId(?string $id)
84  {
85  $this->id = $id;
86 
87  return $this;
88  }
89 
94  public function withValue(?CartDiscountValue $value)
95  {
96  $this->value = $value;
97 
98  return $this;
99  }
100 
105  public function withTarget(?CartDiscountTarget $target)
106  {
107  $this->target = $target;
108 
109  return $this;
110  }
111 
117  {
118  $this->value = $value;
119 
120  return $this;
121  }
122 
128  {
129  $this->target = $target;
130 
131  return $this;
132  }
133 
134  public function build(): DirectDiscount
135  {
136  return new DirectDiscountModel(
137  $this->id,
138  $this->value instanceof CartDiscountValueBuilder ? $this->value->build() : $this->value,
139  $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target
140  );
141  }
142 
143  public static function of(): DirectDiscountBuilder
144  {
145  return new self();
146  }
147 }