@@ 799-810 (lines=12) @@ | ||
796 | * |
|
797 | * @return Map |
|
798 | */ |
|
799 | public function filter(callable $callback = null): Map |
|
800 | { |
|
801 | $filtered = new self(); |
|
802 | ||
803 | foreach ($this as $key => $value) { |
|
804 | if ($callback ? $callback($key, $value) : $value) { |
|
805 | $filtered->put($key, $value); |
|
806 | } |
|
807 | } |
|
808 | ||
809 | return $filtered; |
|
810 | } |
|
811 | ||
812 | /** |
|
813 | * Returns the value associated with a key, or an optional default if the |
@@ 252-263 (lines=12) @@ | ||
249 | * |
|
250 | * @return Map |
|
251 | */ |
|
252 | public function filter(callable $callback = null): Map |
|
253 | { |
|
254 | $filtered = new self(); |
|
255 | ||
256 | foreach ($this as $key => $value) { |
|
257 | if ($callback ? $callback($key, $value) : $value) { |
|
258 | $filtered->put($key, $value); |
|
259 | } |
|
260 | } |
|
261 | ||
262 | return $filtered; |
|
263 | } |
|
264 | ||
265 | /** |
|
266 | * Returns the value associated with a key, or an optional default if the |