src/DS/Traits/TraitSequence.php
public function filter(?callable $callback = null): Sequence
    {
        if (is_null($callback)) {
            return $this->duplicate($this->items->filter());
        }

        return $this->duplicate($this->items->filter($callback));
    }
public function filter(?callable $callback = null): Sequence
    {
        if (is_null($callback)) {
            return $this->duplicate($this->items->filter());
        }

        return $this->duplicate($this->items->filter($callback));
    }
public function filter ( ? callable $ callback = null ) : Sequence { if ( is_null ( $ callback ) ) { return $ this -> duplicate ( $ this -> items -> filter ( ) ) ; } return $ this -> duplicate ( $ this -> items -> filter ( $ callback ) ) ; }
Returns a new sequence containing only the values for which a callback
returns true. A boolean test will be used if a callback is not provided.

@param callable|null $callback Accepts a value, returns a boolean result:
true : include the value,
false: skip the value.

@return \PlanB\DS\Sequence
Returns a new sequence containing only the values for which a callback returns true . A boolean test will be used if a callback is not provided .