Swoole.Class.php 825 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Mall\Framework\Core;
  3. class Swoole
  4. {
  5. static protected $instance;
  6. static public function getInstance($options = [], $driver = 'Client')
  7. {
  8. $driver = $driver ?: 'Client';
  9. if (!is_array($options) && !$options) {
  10. throw new \Exception('Need default Swoole ' . $driver . ' config');
  11. }
  12. /*$key = $driver . md5(implode(',', $options)) . $driver;
  13. if (!isset(self::$instance[$key])) {
  14. $class = 'Mall\\Framework\\Swoole\\' . ucwords(strtolower($driver));
  15. if(class_exists($class)) {
  16. self::$instance[$key] = new $class($options);
  17. }
  18. }
  19. return self::$instance[$key];
  20. */
  21. $class = 'Mall\\Framework\\Swoole\\' . ucwords($driver);
  22. return new $class($options);
  23. }
  24. }