public function filter(callable $predicate)
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            if ($predicate($key, $value)) {
                $items[$key] = $value;
            }
        }

        return $this->createFrom($items);
    }
public function filter(callable $predicate)
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            if ($predicate($key, $value)) {
                $items[$key] = $value;
            }
        }

        return $this->createFrom($items);
    }
Returns a bag with the items that satisfy the `$predicate`.

Keys are preserved, so lists could need to be re-indexed.

Note: This differs from {@see array_filter} in that the `$predicate` is passed `$key` first, then `$value`.

@param callable $predicate Function is passed `($key, $value)`

@return static