lithium\util\Collection::find()

public method

Filters a copy of the items in the collection.

Parameters

  • callback $filter

    Callback to use for filtering.

  • array $options

    The available options are:

    • 'collect': If true, the results will be returned wrapped in a new Collection object or subclass. Defaults to true.

Returns

mixed

The filtered items. Will be an array unless 'collect' is defined in the $options argument, then an instance of this class will be returned.

Source

	public function find($filter, array $options = []) {
		$defaults = ['collect' => true];
		$options += $defaults;
		$data = array_filter($this->_data, $filter);

		if ($options['collect']) {
			$class = get_class($this);
			$data = new $class(compact('data'));
		}
		return $data;
	}