private function _filter()
{
$items = $this->_items;
$mismatch = [];
$strict = false;
if (func_num_args() == 1 && is_callable(func_get_arg(0))) {
$func = func_get_arg(0);
} elseif (func_num_args() == 2 && !is_array(func_get_arg(0)) && !is_array(func_get_arg(1))) {
$filters[][func_get_arg(0)] = func_get_arg(1);
} else {
foreach (func_get_args() as $arg) {
if (is_array($arg)) {
$filters[] = $arg;
}
}
}
if ($filters) {
foreach ($filters as $key => $set) {
foreach ($items as $key => $item) {
$mis = 0;
foreach ($set as $k => $v) {
if ($item->{$k} != $v) {
$mis++;
}
}
if ($strict && count($set) == $mis || $mis) {
$mismatch[$key]++;
}
}
}
}
if ($func) {
foreach ($items as $key => $item) {
if (!$func($item, $key)) {
$mismatch[$key] = $key;
break;
}
}
}
foreach ($items as $key => $value) {
if (array_key_exists($key, $mismatch) && ($func || $mismatch[$key] == count($filters))) {
$trash[] = $items[$key];
} else {
$newitems[] = $items[$key];
}
}
return ['yes' => $newitems, 'no' => $trash];
}