runInSwoole = extension_loaded('swoole'); if (defined('SWOOLE_HOOK_NATIVE_CURL')) { $this->nativeCurlHook = SWOOLE_HOOK_NATIVE_CURL; } } public function create(array $options = []): Client { $stack = null; if ( $this->runInSwoole && Coroutine::inCoroutine() && (Runtime::getHookFlags() & $this->nativeCurlHook) == 0 ) { $stack = HandlerStack::create(new CoroutineHandler()); } $config = array_replace(['handler' => $stack], $options); if (method_exists($this->container, 'make')) { // Create by DI for AOP. return $this->container->make(Client::class, ['config' => $config]); } return new Client($config); } }