commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
DateTimeImmutableCollection.php
1<?php
2
3declare(strict_types=1);
10namespace Commercetools\Base;
11
13use DateTimeImmutable;
14
21{
28 public function add($value)
29 {
30 if (!$value instanceof DateTimeImmutable) {
31 throw new InvalidArgumentException();
32 }
33 $this->store($value);
34
35 return $this;
36 }
37
41 protected function mapper()
42 {
43 return function (int $index): ?DateTimeImmutable {
44 $data = $this->get($index);
45 if (!is_null($data) && !$data instanceof DateTimeImmutable) {
46 $data = new DateTimeImmutable((string)$data);
47 $this->set($data, $index);
48 }
49 return $data;
50 };
51 }
52}