commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CartDiscountPatternTargetModel.php
1<?php
2
3declare(strict_types=1);
10
15use stdClass;
16
21{
22 public const DISCRIMINATOR_VALUE = 'pattern';
27 protected $type;
28
33 protected $triggerPattern;
34
39 protected $targetPattern;
40
45 protected $maxOccurrence;
46
51 protected $selectionMode;
52
53
57 public function __construct(
60 ?int $maxOccurrence = null,
61 ?string $selectionMode = null,
62 ?string $type = null
63 ) {
64 $this->triggerPattern = $triggerPattern;
65 $this->targetPattern = $targetPattern;
66 $this->maxOccurrence = $maxOccurrence;
67 $this->selectionMode = $selectionMode;
68 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
69 }
70
75 public function getType()
76 {
77 if (is_null($this->type)) {
79 $data = $this->raw(self::FIELD_TYPE);
80 if (is_null($data)) {
81 return null;
82 }
83 $this->type = (string) $data;
84 }
85
86 return $this->type;
87 }
88
98 public function getTriggerPattern()
99 {
100 if (is_null($this->triggerPattern)) {
102 $data = $this->raw(self::FIELD_TRIGGER_PATTERN);
103 if (is_null($data)) {
104 return null;
105 }
106 $this->triggerPattern = PatternComponentCollection::fromArray($data);
107 }
108
110 }
111
119 public function getTargetPattern()
120 {
121 if (is_null($this->targetPattern)) {
123 $data = $this->raw(self::FIELD_TARGET_PATTERN);
124 if (is_null($data)) {
125 return null;
126 }
127 $this->targetPattern = PatternComponentCollection::fromArray($data);
128 }
129
131 }
132
140 public function getMaxOccurrence()
141 {
142 if (is_null($this->maxOccurrence)) {
144 $data = $this->raw(self::FIELD_MAX_OCCURRENCE);
145 if (is_null($data)) {
146 return null;
147 }
148 $this->maxOccurrence = (int) $data;
149 }
150
152 }
153
160 public function getSelectionMode()
161 {
162 if (is_null($this->selectionMode)) {
164 $data = $this->raw(self::FIELD_SELECTION_MODE);
165 if (is_null($data)) {
166 return null;
167 }
168 $this->selectionMode = (string) $data;
169 }
170
172 }
173
174
179 {
180 $this->triggerPattern = $triggerPattern;
181 }
182
187 {
188 $this->targetPattern = $targetPattern;
189 }
190
194 public function setMaxOccurrence(?int $maxOccurrence): void
195 {
196 $this->maxOccurrence = $maxOccurrence;
197 }
198
202 public function setSelectionMode(?string $selectionMode): void
203 {
204 $this->selectionMode = $selectionMode;
205 }
206}
__construct(?PatternComponentCollection $triggerPattern=null, ?PatternComponentCollection $targetPattern=null, ?int $maxOccurrence=null, ?string $selectionMode=null, ?string $type=null)
static fromArray(array $data)