Scalr\Model\Collections\ArrayCollection::__call PHP Метод

__call() публичный Метод

Implements some convenient magic methods
public __call ( string $name, array $args ) : AbstractEntity
$name string The method name
$args array The arguments
Результат Scalr\Model\AbstractEntity Returns array of the found entities
    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)));
    }