public function __call($method, $args)
{
preg_match('/^[W|w]here([a-zA-Z0-9_]+)$/', $method, $matches);
if ($matches) {
$attribute = strtolower($matches[1]);
} else {
return false;
}
$value = $args ? $args[0] : null;
$recursive = isset($args[1]) ? $args[1] : false;
if ($recursive) {
return $this->filterRecursive($attribute, $value);
}
return $this->items->filter(function ($item) use($attribute, $value) {
if (!$item->hasProperty($attribute)) {
return false;
}
if ($item->{$attribute} == $value) {
return true;
}
return false;
})->values();
}