Google.php 787 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\libs\google;
  3. use Symfony\Component\VarExporter\Exception\ClassNotFoundException;
  4. /**
  5. * @desc
  6. *
  7. * @method static \App\libs\google\Gateways\GoogleOauth GoogleOauth
  8. */
  9. class Google
  10. {
  11. /**
  12. * @desc
  13. *
  14. * @param string $method
  15. * @param array $arguments
  16. */
  17. public static function __callStatic($method, $arguments)
  18. {
  19. return self::make($method, ...$arguments);
  20. }
  21. private static function make($method)
  22. {
  23. $value = ucwords(str_replace(['-', '_'], ' ', $method));
  24. $gateway = __NAMESPACE__ . '\\Gateways\\' . $value;
  25. if (class_exists($gateway)) {
  26. return new $gateway();
  27. }
  28. throw new ClassNotFoundException("Gateway [{$method}] Not Exists", $gateway);
  29. }
  30. }