WeChat.php 856 B

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