lithium\util\Collection::find()
Filters a copy of the items in the collection.
Parameters
-
callback
$filter
Callback to use for filtering.
-
array
$options
The available options are:
'collect'
: Iftrue
, the results will be returned wrapped in a newCollection
object or subclass. Defaults totrue
.
Returns
mixedThe 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;
}