commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
NestedAttribute.php
1<?php
2
3declare(strict_types=1);
4
6
9use stdClass;
10
17{
25 public function add($value)
26 {
27 if (!$value instanceof Attribute) {
28 throw new InvalidArgumentException();
29 }
30 $this->store($value);
31
32 return $this;
33 }
34
38 protected function mapper()
39 {
40 return function (int $index): ?Attribute {
41 $data = $this->get($index);
42 if ($data instanceof Attribute || $data == null) {
43 return $data;
44 }
45 $data = AttributeModel::of($data);
46 $this->set($data, $index);
47
48 return $data;
49 };
50 }
51}