Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | public function create(?array $options = []): ClientInterface |
||
28 | { |
||
29 | if ($this->container->has(HttpClientInterface::class)) { |
||
30 | if (($http = $this->container->get(HttpClientInterface::class)) instanceof ClientInterface) { |
||
31 | return $http; |
||
32 | } |
||
33 | |||
34 | throw new InvalidConfigException(Exception::CONFIG_HTTP_CLIENT_INVALID, '配置异常: `HttpClient` 不符合 PSR 规范,可能你需要安装 `GuzzleHttp:^7`'); |
||
35 | } |
||
36 | |||
37 | if (!class_exists(Client::class)) { |
||
38 | throw new InvalidConfigException(Exception::CONFIG_HTTP_CLIENT_INVALID, '配置异常: 没有可用的 `HttpClient`,可能你需要安装 `GuzzleHttp:^7`'); |
||
39 | } |
||
40 | |||
41 | return new Client($options); |
||
42 | } |
||
44 |