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
223 public function getExpiresAt()
224 {
225 if (is_null($this->expiresAt)) {
227 $data = $this->raw(self::FIELD_EXPIRES_AT);
228 if (is_null($data)) {
229 return null;
230 }
231 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
232 if (false === $data) {
233 return null;
234 }
235 $this->expiresAt = $data;
236 }
237
238 return $this->expiresAt;
239 }
240
241
245 public function setKey(?string $key): void
246 {
247 $this->key = $key;
248 }
249
253 public function setResourceType(?string $resourceType): void
254 {
255 $this->resourceType = $resourceType;
256 }
257
261 public function setVersion(?int $version): void
262 {
263 $this->version = $version;
264 }
265
270 {
271 $this->retentionPolicy = $retentionPolicy;
272 }
273
277 public function setCreatedAt(?DateTimeImmutable $createdAt): void
278 {
279 $this->createdAt = $createdAt;
280 }
281
285 public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
286 {
287 $this->lastModifiedAt = $lastModifiedAt;
288 }
289
293 public function setExpiresAt(?DateTimeImmutable $expiresAt): void
294 {
295 $this->expiresAt = $expiresAt;
296 }
297
298
299 #[\ReturnTypeWillChange]
300 public function jsonSerialize()
301 {
302 $data = $this->toArray();
303 if (isset($data[ImportContainer::FIELD_CREATED_AT]) && $data[ImportContainer::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
304 $data[ImportContainer::FIELD_CREATED_AT] = $data[ImportContainer::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
305 }
306
307 if (isset($data[ImportContainer::FIELD_LAST_MODIFIED_AT]) && $data[ImportContainer::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
308 $data[ImportContainer::FIELD_LAST_MODIFIED_AT] = $data[ImportContainer::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
309 }
310
311 if (isset($data[ImportContainer::FIELD_EXPIRES_AT]) && $data[ImportContainer::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) {
312 $data[ImportContainer::FIELD_EXPIRES_AT] = $data[ImportContainer::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
313 }
314 return (object) $data;
315 }
316}
__construct(?string $key=null, ?string $resourceType=null, ?int $version=null, ?RetentionPolicy $retentionPolicy=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null, ?DateTimeImmutable $expiresAt=null)