| @@ 131-150 (lines=20) @@ | ||
| 128 | return $this; |
|
| 129 | } |
|
| 130 | ||
| 131 | public function setTemplateIds(array $templateIds) |
|
| 132 | { |
|
| 133 | $validation = \array_reduce($templateIds, |
|
| 134 | function ($carry, $item) { |
|
| 135 | if ($carry === false) { |
|
| 136 | return false; |
|
| 137 | } |
|
| 138 | ||
| 139 | return $item instanceof InstanceIdentifier; |
|
| 140 | }); |
|
| 141 | ||
| 142 | if ($validation === false) { |
|
| 143 | throw new \UnexpectedValueException(sprintf("The values of templateIds" |
|
| 144 | . " must contains only %s", InstanceIdentifier::class)); |
|
| 145 | } |
|
| 146 | ||
| 147 | $this->templateIds = $templateIds; |
|
| 148 | ||
| 149 | return $this; |
|
| 150 | } |
|
| 151 | ||
| 152 | public function addTemplateId(InstanceIdentifier $templateId) |
|
| 153 | { |
|
| @@ 172-192 (lines=21) @@ | ||
| 169 | * @param InstanceIdentifier[] $templateIds |
|
| 170 | * @return $this |
|
| 171 | */ |
|
| 172 | public function setTemplateIds(array $templateIds) |
|
| 173 | { |
|
| 174 | // check that each element is an instance of InstanceIdentifier |
|
| 175 | $result = \array_reduce($templateIds, function ($carry, $current) { |
|
| 176 | if ($carry === false) { |
|
| 177 | return false; |
|
| 178 | } |
|
| 179 | ||
| 180 | return $current instanceof InstanceIdentifier; |
|
| 181 | }); |
|
| 182 | ||
| 183 | if ($result === false) { |
|
| 184 | throw new \RuntimeException(sprintf("the templateIds must be " |
|
| 185 | . "instance of %s", InstanceIdentifier::class)); |
|
| 186 | } |
|
| 187 | ||
| 188 | $this->templateIds = $templateIds; |
|
| 189 | ||
| 190 | ||
| 191 | return $this; |
|
| 192 | } |
|
| 193 | ||
| 194 | public function addTemplateId(InstanceIdentifier $id) |
|
| 195 | { |
|