__\__::__loader PHP Method

__loader() public static method

public static __loader ( $name, $arguments )
    public static function __loader($name, $arguments)
    {
        if (count(self::$functions) == 0) {
            foreach (self::$modules as $key => $value) {
                foreach (glob(__DIR__ . '/' . $value . '/*.php', GLOB_BRACE) as $function) {
                    $path = explode('.', str_replace(__DIR__ . '/', '', $function));
                    $alias = str_replace('/', '\\', array_shift($path));
                    if (!function_exists($alias)) {
                        self::$functions[] = $alias;
                        require $function;
                    }
                }
            }
        }
        foreach (self::$functions as $key => $value) {
            if (strpos($value, $name)) {
                return call_user_func_array($value, $arguments);
            }
        }
        throw new \Exception('Invalid function: ' . $name);
    }