酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Factory.php 1.6 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace EasyWeChat;
  11. /**
  12. * Class Factory.
  13. *
  14. * @method static \EasyWeChat\Payment\Application payment(array $config)
  15. * @method static \EasyWeChat\MiniProgram\Application miniProgram(array $config)
  16. * @method static \EasyWeChat\OpenPlatform\Application openPlatform(array $config)
  17. * @method static \EasyWeChat\OfficialAccount\Application officialAccount(array $config)
  18. * @method static \EasyWeChat\BasicService\Application basicService(array $config)
  19. * @method static \EasyWeChat\Work\Application work(array $config)
  20. * @method static \EasyWeChat\OpenWork\Application openWork(array $config)
  21. * @method static \EasyWeChat\MicroMerchant\Application microMerchant(array $config)
  22. */
  23. class Factory
  24. {
  25. /**
  26. * @param string $name
  27. * @param array $config
  28. *
  29. * @return \EasyWeChat\Kernel\ServiceContainer
  30. */
  31. public static function make($name, array $config)
  32. {
  33. $namespace = Kernel\Support\Str::studly($name);
  34. $application = "\\EasyWeChat\\{$namespace}\\Application";
  35. return new $application($config);
  36. }
  37. /**
  38. * Dynamically pass methods to the application.
  39. *
  40. * @param string $name
  41. * @param array $arguments
  42. *
  43. * @return mixed
  44. */
  45. public static function __callStatic($name, $arguments)
  46. {
  47. return self::make($name, ...$arguments);
  48. }
  49. }