@@ 191-209 (lines=19) @@ | ||
188 | * @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an object |
|
189 | * @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is NULL |
|
190 | */ |
|
191 | public function exists($key) |
|
192 | { |
|
193 | if (is_null($key)) { |
|
194 | throw new NullPointerException('Passed key is null'); |
|
195 | } |
|
196 | if (!is_object($key)) { |
|
197 | throw new InvalidKeyException('Passed key has to be an object'); |
|
198 | } |
|
199 | // run over all keys and check if one is equal to the passed one |
|
200 | foreach ($this->keys as $id => $value) { |
|
201 | // if the actual is equal to the passed key .. |
|
202 | if ($key == $value) { |
|
203 | // return TRUE if the key is found |
|
204 | return true; |
|
205 | } |
|
206 | } |
|
207 | // return FALSE if the key is not found |
|
208 | return false; |
|
209 | } |
|
210 | ||
211 | /** |
|
212 | * This returns true if the Collection has no |
@@ 85-103 (lines=19) @@ | ||
82 | * @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an object |
|
83 | * @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is NULL |
|
84 | */ |
|
85 | public function exists($key) |
|
86 | { |
|
87 | if (is_null($key)) { |
|
88 | throw new NullPointerException('Passed key is null'); |
|
89 | } |
|
90 | if (! is_object($key)) { |
|
91 | throw new InvalidKeyException('Passed key has to be an object'); |
|
92 | } |
|
93 | // run over all keys and check if one is equal to the passed one |
|
94 | foreach ($this->keys as $id => $value) { |
|
95 | // if the actual is equal to the passed key .. |
|
96 | if ($key === $value) { |
|
97 | // return TRUE if the key is found |
|
98 | return true; |
|
99 | } |
|
100 | } |
|
101 | // return FALSE if the key is not found |
|
102 | return false; |
|
103 | } |
|
104 | ||
105 | /** |
|
106 | * This method removes the element that has the passed |