src/Map.php
public function filter($expression)
    {
        $new = new static;

        $this->walk(function ($v, $k) use ($expression, $new) {
            $result = $this->call($expression, $v, $k);
            if ($this->passes($result)) {
                $new[$k] = $v;
            }
        });

        return $new;
    }
public function filter($expression)
    {
        $new = new static;

        $this->walk(function ($v, $k) use ($expression, $new) {
            $result = $this->call($expression, $v, $k);
            if ($this->passes($result)) {
                $new[$k] = $v;
            }
        });

        return $new;
    }
public function filter ( $ expression ) { $ new = new static ; $ this -> walk ( function ( $ v , $ k ) use ( $ expression , $ new ) { $ result = $ this -> call ( $ expression , $ v , $ k ) ; if ( $ this -> passes ( $ result ) ) { $ new [ $ k ] = $ v ; } } ) ; return $ new ; }
Apply the filter to every element, creating a new map with only those
elements from the original map that do not fail this filter.

The filter expressions receives two arguments:
- The current value
- The current key

If the filter returns exactly boolean false, the element is not copied
into the new map.  Otherwise, it is.  Keys from the original map carry
into the new map.

@param callable|string $expression
@return new static
@api
Apply the filter to every element creating a new map with only those elements from the original map that do not fail this filter .