@@ 69-80 (lines=12) @@ | ||
66 | * @throws NoDuplicateAllowedException When try to add an object already added |
|
67 | * @since 5.0.0 |
|
68 | */ |
|
69 | public function offsetSet($offset, $value) |
|
70 | { |
|
71 | if ($this->contains($value)) { |
|
72 | throw new NoDuplicateAllowedException("Object already inserted"); |
|
73 | } |
|
74 | ||
75 | if (is_null($offset)) { |
|
76 | $this->data[] = $value; |
|
77 | } else { |
|
78 | $this->data[$offset] = $value; |
|
79 | } |
|
80 | } |
|
81 | ||
82 | /** |
|
83 | * Offset to unset |
@@ 113-124 (lines=12) @@ | ||
110 | * @throws \TypeError When try to add type not managed by this collection |
|
111 | * @since 5.0.0 |
|
112 | */ |
|
113 | public function offsetSet($offset, $value) |
|
114 | { |
|
115 | if ($this->validateType($value) === false) { |
|
116 | throw new \TypeError("Object cannot be added. Type not managed by this collection"); |
|
117 | } |
|
118 | ||
119 | if (is_null($offset)) { |
|
120 | $this->data[] = $value; |
|
121 | } else { |
|
122 | $this->data[$offset] = $value; |
|
123 | } |
|
124 | } |
|
125 | ||
126 | /** |
|
127 | * Offset to unset |