commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ImportContainerModel.php
1<?php
2
3declare(strict_types=1);
10
15use DateTimeImmutable;
16use stdClass;
17
22{
27 protected $key;
28
33 protected $resourceType;
34
39 protected $version;
40
46
51 protected $createdAt;
52
57 protected $lastModifiedAt;
58
63 protected $expiresAt;
64
65
69 public function __construct(
70 ?string $key = null,
71 ?string $resourceType = null,
72 ?int $version = null,
74 ?DateTimeImmutable $createdAt = null,
75 ?DateTimeImmutable $lastModifiedAt = null,
76 ?DateTimeImmutable $expiresAt = null
77 ) {
78 $this->key = $key;
79 $this->resourceType = $resourceType;
80 $this->version = $version;
81 $this->retentionPolicy = $retentionPolicy;
82 $this->createdAt = $createdAt;
83 $this->lastModifiedAt = $lastModifiedAt;
84 $this->expiresAt = $expiresAt;
85 }
86
93 public function getKey()
94 {
95 if (is_null($this->key)) {
97 $data = $this->raw(self::FIELD_KEY);
98 if (is_null($data)) {
99 return null;
100 }
101 $this->key = (string) $data;
102 }
103
104 return $this->key;
105 }
106
113 public function getResourceType()
114 {
115 if (is_null($this->resourceType)) {
117 $data = $this->raw(self::FIELD_RESOURCE_TYPE);
118 if (is_null($data)) {
119 return null;
120 }
121 $this->resourceType = (string) $data;
122 }
123
124 return $this->resourceType;
125 }
126
133 public function getVersion()
134 {
135 if (is_null($this->version)) {
137 $data = $this->raw(self::FIELD_VERSION);
138 if (is_null($data)) {
139 return null;
140 }
141 $this->version = (int) $data;
142 }
143
144 return $this->version;
145 }
146
153 public function getRetentionPolicy()
154 {
155 if (is_null($this->retentionPolicy)) {
157 $data = $this->raw(self::FIELD_RETENTION_POLICY);
158 if (is_null($data)) {
159 return null;
160 }
162 $this->retentionPolicy = $className::of($data);
163 }
164
166 }
167
174 public function getCreatedAt()
175 {
176 if (is_null($this->createdAt)) {
178 $data = $this->raw(self::FIELD_CREATED_AT);
179 if (is_null($data)) {
180 return null;
181 }
182 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
183 if (false === $data) {
184 return null;
185 }
186 $this->createdAt = $data;
187 }
188
189 return $this->createdAt;
190 }
191
198 public function getLastModifiedAt()
199 {
200 if (is_null($this->lastModifiedAt)) {
202 $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
203 if (is_null($data)) {
204 return null;
205 }
206 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
207 if (false === $data) {
208 return null;
209 }
210 $this->lastModifiedAt = $data;
211 }
212
214 }
215
222 public function getExpiresAt()
223 {
224 if (is_null($this->expiresAt)) {
226 $data = $this->raw(self::FIELD_EXPIRES_AT);
227 if (is_null($data)) {
228 return null;
229 }
230 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
231 if (false === $data) {
232 return null;
233 }
234 $this->expiresAt = $data;
235 }
236
237 return $this->expiresAt;
238 }
239
240
244 public function setKey(?string $key): void
245 {
246 $this->key = $key;
247 }
248
252 public function setResourceType(?string $resourceType): void
253 {
254 $this->resourceType = $resourceType;
255 }
256
260 public function setVersion(?int $version): void
261 {
262 $this->version = $version;
263 }
264
269 {
270 $this->retentionPolicy = $retentionPolicy;
271 }
272
276 public function setCreatedAt(?DateTimeImmutable $createdAt): void
277 {
278 $this->createdAt = $createdAt;
279 }
280
284 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
285 {
286 $this->lastModifiedAt = $lastModifiedAt;
287 }
288
292 public function setExpiresAt(?DateTimeImmutable $expiresAt): void
293 {
294 $this->expiresAt = $expiresAt;
295 }
296
297
298 #[\ReturnTypeWillChange]
299 public function jsonSerialize()
300 {
301 $data = $this->toArray();
302 if (isset($data[ImportContainer::FIELD_CREATED_AT]) && $data[ImportContainer::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
303 $data[ImportContainer::FIELD_CREATED_AT] = $data[ImportContainer::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
304 }
305
306 if (isset($data[ImportContainer::FIELD_LAST_MODIFIED_AT]) && $data[ImportContainer::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
307 $data[ImportContainer::FIELD_LAST_MODIFIED_AT] = $data[ImportContainer::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
308 }
309
310 if (isset($data[ImportContainer::FIELD_EXPIRES_AT]) && $data[ImportContainer::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) {
311 $data[ImportContainer::FIELD_EXPIRES_AT] = $data[ImportContainer::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
312 }
313 return (object) $data;
314 }
315}
__construct(?string $key=null, ?string $resourceType=null, ?int $version=null, ?RetentionPolicy $retentionPolicy=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?DateTimeImmutable $expiresAt=null)