commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
CustomerTokenModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use DateTimeImmutable;
16 use stdClass;
17 
21 final class CustomerTokenModel extends JsonObjectModel implements CustomerToken
22 {
27  protected $id;
28 
33  protected $customerId;
34 
39  protected $value;
40 
45  protected $expiresAt;
46 
51  protected $createdAt;
52 
57  protected $lastModifiedAt;
58 
59 
63  public function __construct(
64  ?string $id = null,
65  ?string $customerId = null,
66  ?string $value = null,
67  ?DateTimeImmutable $expiresAt = null,
68  ?DateTimeImmutable $createdAt = null,
69  ?DateTimeImmutable $lastModifiedAt = null
70  ) {
71  $this->id = $id;
72  $this->customerId = $customerId;
73  $this->value = $value;
74  $this->expiresAt = $expiresAt;
75  $this->createdAt = $createdAt;
76  $this->lastModifiedAt = $lastModifiedAt;
77  }
78 
85  public function getId()
86  {
87  if (is_null($this->id)) {
89  $data = $this->raw(self::FIELD_ID);
90  if (is_null($data)) {
91  return null;
92  }
93  $this->id = (string) $data;
94  }
95 
96  return $this->id;
97  }
98 
105  public function getCustomerId()
106  {
107  if (is_null($this->customerId)) {
109  $data = $this->raw(self::FIELD_CUSTOMER_ID);
110  if (is_null($data)) {
111  return null;
112  }
113  $this->customerId = (string) $data;
114  }
115 
116  return $this->customerId;
117  }
118 
125  public function getValue()
126  {
127  if (is_null($this->value)) {
129  $data = $this->raw(self::FIELD_VALUE);
130  if (is_null($data)) {
131  return null;
132  }
133  $this->value = (string) $data;
134  }
135 
136  return $this->value;
137  }
138 
145  public function getExpiresAt()
146  {
147  if (is_null($this->expiresAt)) {
149  $data = $this->raw(self::FIELD_EXPIRES_AT);
150  if (is_null($data)) {
151  return null;
152  }
153  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
154  if (false === $data) {
155  return null;
156  }
157  $this->expiresAt = $data;
158  }
159 
160  return $this->expiresAt;
161  }
162 
169  public function getCreatedAt()
170  {
171  if (is_null($this->createdAt)) {
173  $data = $this->raw(self::FIELD_CREATED_AT);
174  if (is_null($data)) {
175  return null;
176  }
177  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
178  if (false === $data) {
179  return null;
180  }
181  $this->createdAt = $data;
182  }
183 
184  return $this->createdAt;
185  }
186 
193  public function getLastModifiedAt()
194  {
195  if (is_null($this->lastModifiedAt)) {
197  $data = $this->raw(self::FIELD_LAST_MODIFIED_AT);
198  if (is_null($data)) {
199  return null;
200  }
201  $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
202  if (false === $data) {
203  return null;
204  }
205  $this->lastModifiedAt = $data;
206  }
207 
208  return $this->lastModifiedAt;
209  }
210 
211 
215  public function setId(?string $id): void
216  {
217  $this->id = $id;
218  }
219 
223  public function setCustomerId(?string $customerId): void
224  {
225  $this->customerId = $customerId;
226  }
227 
231  public function setValue(?string $value): void
232  {
233  $this->value = $value;
234  }
235 
239  public function setExpiresAt(?DateTimeImmutable $expiresAt): void
240  {
241  $this->expiresAt = $expiresAt;
242  }
243 
247  public function setCreatedAt(?DateTimeImmutable $createdAt): void
248  {
249  $this->createdAt = $createdAt;
250  }
251 
255  public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void
256  {
257  $this->lastModifiedAt = $lastModifiedAt;
258  }
259 
260 
261  #[\ReturnTypeWillChange]
262  public function jsonSerialize()
263  {
264  $data = $this->toArray();
265  if (isset($data[CustomerToken::FIELD_EXPIRES_AT]) && $data[CustomerToken::FIELD_EXPIRES_AT] instanceof \DateTimeImmutable) {
266  $data[CustomerToken::FIELD_EXPIRES_AT] = $data[CustomerToken::FIELD_EXPIRES_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
267  }
268 
269  if (isset($data[CustomerToken::FIELD_CREATED_AT]) && $data[CustomerToken::FIELD_CREATED_AT] instanceof \DateTimeImmutable) {
270  $data[CustomerToken::FIELD_CREATED_AT] = $data[CustomerToken::FIELD_CREATED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
271  }
272 
273  if (isset($data[CustomerToken::FIELD_LAST_MODIFIED_AT]) && $data[CustomerToken::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) {
274  $data[CustomerToken::FIELD_LAST_MODIFIED_AT] = $data[CustomerToken::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
275  }
276  return (object) $data;
277  }
278 }
__construct(?string $id=null, ?string $customerId=null, ?string $value=null, ?DateTimeImmutable $expiresAt=null, ?DateTimeImmutable $createdAt=null, ?DateTimeImmutable $lastModifiedAt=null)
setLastModifiedAt(?DateTimeImmutable $lastModifiedAt)