commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
lib
commercetools-base
src
Base
DateTimeImmutableCollection.php
1
<?php
2
3
declare(strict_types=1);
10
namespace
Commercetools\Base
;
11
12
use
Commercetools\Exception\InvalidArgumentException
;
13
use DateTimeImmutable;
14
20
class
DateTimeImmutableCollection
extends
MapperScalarSequence
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
}
Commercetools\Base\DateTimeImmutableCollection
Definition:
DateTimeImmutableCollection.php:21
Commercetools\Base\DateTimeImmutableCollection\mapper
mapper()
Definition:
DateTimeImmutableCollection.php:41
Commercetools\Base\DateTimeImmutableCollection\add
add($value)
Definition:
DateTimeImmutableCollection.php:28
Commercetools\Base\MapperScalarSequence
Definition:
MapperScalarSequence.php:19
Commercetools\Base\MapperScalarSequence\store
store($value)
Definition:
MapperScalarSequence.php:106
Commercetools\Exception\InvalidArgumentException
Definition:
InvalidArgumentException.php:15
Commercetools\Base
Definition:
MapperArraySequence.php:10
Generated by
1.9.1