| @@ 76-87 (lines=12) @@ | ||
| 73 | /** |
|
| 74 | * {@inheritdoc} |
|
| 75 | */ |
|
| 76 | public function add(ItemInterface $item) |
|
| 77 | { |
|
| 78 | if ($this->has($item->getId())) { |
|
| 79 | throw new \DomainException(sprintf( |
|
| 80 | 'Failed adding item "%s": an item with that id has already been added.', |
|
| 81 | $item->getId() |
|
| 82 | )); |
|
| 83 | } |
|
| 84 | $this->items[$item->getId()] = $item; |
|
| 85 | ||
| 86 | return $this; |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * {@inheritdoc} |
|
| @@ 92-102 (lines=11) @@ | ||
| 89 | /** |
|
| 90 | * {@inheritdoc} |
|
| 91 | */ |
|
| 92 | public function replace($id, ItemInterface $item) |
|
| 93 | { |
|
| 94 | if ($this->has($id)) { |
|
| 95 | $this->items[$id] = $item; |
|
| 96 | } else { |
|
| 97 | throw new \DomainException(sprintf( |
|
| 98 | 'Failed replacing item "%s": item does not exist.', |
|
| 99 | $item->getId() |
|
| 100 | )); |
|
| 101 | } |
|
| 102 | } |
|
| 103 | ||
| 104 | /** |
|
| 105 | * {@inheritdoc} |
|