commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
DirectDiscountDraftBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
20 use stdClass;
21 
25 final class DirectDiscountDraftBuilder implements Builder
26 {
31  private $value;
32 
37  private $target;
38 
45  public function getValue()
46  {
47  return $this->value instanceof CartDiscountValueDraftBuilder ? $this->value->build() : $this->value;
48  }
49 
57  public function getTarget()
58  {
59  return $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target;
60  }
61 
66  public function withValue(?CartDiscountValueDraft $value)
67  {
68  $this->value = $value;
69 
70  return $this;
71  }
72 
77  public function withTarget(?CartDiscountTarget $target)
78  {
79  $this->target = $target;
80 
81  return $this;
82  }
83 
89  {
90  $this->value = $value;
91 
92  return $this;
93  }
94 
99  public function withTargetBuilder(?CartDiscountTargetBuilder $target)
100  {
101  $this->target = $target;
102 
103  return $this;
104  }
105 
106  public function build(): DirectDiscountDraft
107  {
108  return new DirectDiscountDraftModel(
109  $this->value instanceof CartDiscountValueDraftBuilder ? $this->value->build() : $this->value,
110  $this->target instanceof CartDiscountTargetBuilder ? $this->target->build() : $this->target
111  );
112  }
113 
114  public static function of(): DirectDiscountDraftBuilder
115  {
116  return new self();
117  }
118 }