Bluz\Common\Helper::__call PHP Method

__call() public method

Call magic helper
public __call ( string $method, array $args ) : mixed
$method string
$args array
return mixed
    public function __call($method, $args)
    {
        // Setup key
        $key = static::class . ':' . $method;
        // Call callable helper structure (function or class)
        if (isset($this->helpers[$key]) && is_callable($this->helpers[$key])) {
            return $this->helpers[$key](...$args);
        }
        // Try to find helper file
        foreach ($this->helpersPath as $helperPath) {
            $helperPath = realpath($helperPath . '/' . ucfirst($method) . '.php');
            if ($helperPath) {
                $helperInclude = (include $helperPath);
                if (is_callable($helperInclude)) {
                    $this->helpers[$key] = $helperInclude;
                    return $this->helpers[$key](...$args);
                } else {
                    throw new CommonException("Helper '{$method}' not found in file '{$helperPath}'");
                }
            }
        }
        throw new CommonException("Helper '{$method}' not found for '" . __CLASS__ . "'");
    }