WeChat.php 694 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Services\WeChat;
  3. class WeChat
  4. {
  5. private static $instances = [];
  6. private function __construct()
  7. {
  8. }
  9. public static function __callStatic($name, $publicId)
  10. {
  11. return self::make($name, $publicId);
  12. }
  13. private static function make($name, $publicId)
  14. {
  15. $application = "\\App\Services\WeChat\\{$name}";
  16. return new $application($publicId);
  17. // 单例模式
  18. // if (!isset(static::$instances[$application])) {
  19. // static::$instances[$application] = new $application($publicId);
  20. // }
  21. // return static::$instances[$application];
  22. }
  23. private function __clone()
  24. {
  25. }
  26. }