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