public function __call($name, $args)
{
//Implements findByProperty method set
if (strpos($name, 'filterBy') === 0) {
$property = lcfirst(substr($name, 8));
$value = isset($args[0]) ? $args[0] : null;
return new static(array_filter($this->getArrayCopy(), function ($entity) use($property, $value) {
if (is_object($entity)) {
$ret = property_exists($entity, $property) && $entity->{$property} == $value;
} else {
if (is_array($entity)) {
$ret = array_key_exists($property, $entity) ? $entity[$property] == $value : $value === null;
} else {
$ret = $entity == value;
}
}
return $ret;
}));
}
throw new BadMethodCallException(sprintf("Could not find method %s for class %s", $name, get_class($this)));
}