Lavary\Menu\Builder::__call PHP Method

__call() public method

Search the menu based on an attribute
public __call ( string $method, array $args ) : Lavary\Menu\Item
$method string
$args array
return Lavary\Menu\Item
    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();
    }