<?php

namespace App\libs\google;

use Symfony\Component\VarExporter\Exception\ClassNotFoundException;

/**
 * @desc
 *
 * @method  static \App\libs\google\Gateways\GoogleOauth     GoogleOauth
 */
class Google
{
    /**
     * @desc
     *
     * @param string $method
     * @param array  $arguments
     */
    public static function __callStatic($method, $arguments)
    {
        return self::make($method, ...$arguments);
    }

    private static function make($method)
    {
        $value = ucwords(str_replace(['-', '_'], ' ', $method));

        $gateway = __NAMESPACE__ . '\\Gateways\\' . $value;

        if (class_exists($gateway)) {
            return new $gateway();
        }

        throw new ClassNotFoundException("Gateway [{$method}] Not Exists", $gateway);
    }
}
