WeChat.php 965 B

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