Filter array values by using a callback function.

@param string $callable

@return $this
@throws ArrayObjectException
514349
public function filter($callable = '')
    {
        if ($callable != '' && !$this->isCallable($callable)) {
            throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, [
                '$callable',
                'a callable function or method'
            ]);
        }

        if ($callable == '') {
            // Filter all values equal to FALSE
            $this->val(array_filter($this->val()));
        } else {
            // Filter values using a callback
            $this->val(array_filter($this->val(), $callable));
        }

        return $this;
    }
607905
public function filter($callback)
    {
        $this->assertMutable('Attempting to filter immutable array');
        $this->filters[] = $callback;
        $this->applyFilters();
        return $this;
    }
532949
public function filter(callable $callback = null)
    {
        if (!is_null($callback)) {
            return new static(
                $this->wye,
                array_filter($this->items, $callback, ARRAY_FILTER_USE_BOTH)
            );
        }

        return new static($this->wye, array_filter($this->items));
    }
22674
public function filter(callable $callback): self
    {
        $collection = Factory::create();
        $index      = 0;
        foreach ($this->items as $key => $value) {
            if ($callback($value, $key, $index++)) {
                $collection->set($key, $value);
            }
        }

        return $collection;
    }
1244994
public function filter($callback = null)
    {
        if ($callback !== null)
            $value = array_filter($this->value, $callback);
        else
            $value = array_filter($this->value);

        return $this->setValue($value);
    }
316056
public static function share($callable)
    {
        if (!is_object($callable) || !method_exists($callable, '__invoke')) {
            throw new InvalidArgumentException('Callable is not a Closure or invokable object.');
        }
        
        return function ($c) use ($callable) {
            static $object;

            if (null === $object) {
                $object = $callable($c);
            }

            return $object;
        };
    }
1037776
public function setApplyFilterFunction(callable $function)
    {
        $validator = $this->getCallableValidatorApplyFilters();
        $validator->setCallableFunction($function);

        if ($validator->isValid() === false) {
            throw $validator->getException();
        }

        $this->applyFilterFunction = $function;

        return $this;
    }
1123775
protected function parse($callable)
    {
        list($callable, $args) = $this->parseArgs($callable);

        if ($this->isClassMethod($callable)) {
            $callable = $this->parseClassMethod($callable);
        } elseif ($this->isMutatorMethod($callable)) {
            $callable = [$this, $callable];
        } elseif (!function_exists($callable)) {
            throw new InvalidCallableException("Function [{$callable}] not found.");
        }

        return [$callable, $args];
    }
79198
public function map( $callable ) {
		$items = array();
		$val_type = null;

		foreach ( $this->storage as $key => $val ) {
			$v = call_user_func( $callable, $val, $key );

			if ( ! isset( $val_type ) ) {
				$val_type = gettype( $v );
			}

			$items[ $key ] = $v;
		}

		return new static( $this->get_key_type(), $val_type ? : $this->get_value_type(), $items );
	}
212331
public function filter(callable $callback) : self
    {
        $entries = array_filter($this->getItems()->getArrayCopy(), $callback);
        $this->getItems()->exchangeArray($entries);
        return $this;
    }
1317458
public function where(callable $filter)
    {
        $filtered = [];

        foreach ($this->array as $key => $value) {
            if ($filter($key, $value) === true) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
527270
public function mapWithKeys(callable $callable)
    {
        $result = [];

        foreach ($this->attributes as $key => $attribute)
        {
            $assoc = $callable($attribute, $key);

            foreach ($assoc as $mapKey => $value)
            {
                $result[$mapKey]    =   $value;
            }
        }

        return new static($result);
    }
1243892
public function filter(?callable $callable = null)
	{
		if($callable === null)
		{
			return new static(array_filter($this->items));
		}

		return new static(array_filter($this->items, $callable, ARRAY_FILTER_USE_BOTH));
	}
223895
public static function filter(array $array, callable $callable = NULL) {
    $array = is_callable($callable) ? array_filter($array, $callable) : array_filter($array);
    foreach ($array as &$element) {
      if (is_array($element)) {
        $element = static::filter($element, $callable);
      }
    }

    return $array;
  }
1069905
public static function fromCallable(callable $callable)
    {
        $reflection = Reflection::fromCallable($callable);

        return new self(
                $callable,
                $reflection,
                FunctionSignature::fromReflection($reflection),
                FunctionLocation::fromReflection($reflection),
                FunctionScope::fromReflection($reflection, $callable));
    }
541921
public function filter(callable $fn)
    {
        $this->items = array_values(array_filter($this->items, $fn));

        return $this;
    }
1247072
public function each($callable)
    {
        if ($this instanceof Iterator) {

            if (is_string($callable)) {
                foreach ($this as $obj) {
                    if ($obj->$callable() === false) {
                        break;
                    }
                }

                return $this;
            }

            foreach ($this as $obj) {
                if (call_user_func($callable, $obj) === false) {
                    break;
                }
            }

        } else {
            throw $this->exception('Calling each() on non-iterative object');
        }

        return $this;
    }