@@ 261-272 (lines=12) @@ | ||
258 | * |
|
259 | * @return Map |
|
260 | */ |
|
261 | public function filter(callable $predicate = null): Map |
|
262 | { |
|
263 | $filtered = new self(); |
|
264 | ||
265 | foreach ($this as $key => $value) { |
|
266 | if ($predicate ? $predicate($key, $value) : $value) { |
|
267 | $filtered->put($key, $value); |
|
268 | } |
|
269 | } |
|
270 | ||
271 | return $filtered; |
|
272 | } |
|
273 | ||
274 | /** |
|
275 | * Returns the value associated with a key, or an optional default if the |
@@ 178-189 (lines=12) @@ | ||
175 | * |
|
176 | * @return Set |
|
177 | */ |
|
178 | public function filter(callable $predicate = null): Set |
|
179 | { |
|
180 | $filtered = new self(); |
|
181 | ||
182 | foreach ($this as $value) { |
|
183 | if ($predicate ? $predicate($value) : $value) { |
|
184 | $filtered->add($value); |
|
185 | } |
|
186 | } |
|
187 | ||
188 | return $filtered; |
|
189 | } |
|
190 | ||
191 | /** |
|
192 | * Returns the first value in the set. |