| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 3 |
| CRAP Score | 5.3906 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | 1 | public function createClient(array $config = []) |
|
| 38 | { |
||
| 39 | 1 | if (!class_exists('Http\Client\Curl\Client')) { |
|
| 40 | throw new \LogicException('To use the Curl client you need to install the "php-http/curl-client" package.'); |
||
| 41 | } |
||
| 42 | |||
| 43 | 1 | // Try to resolve curl constant names |
|
| 44 | foreach ($config as $key => $value) { |
||
| 45 | // If the value starts with 'CURL' we assume it is a reference to a constant. |
||
| 46 | if (strpos($key, 'CURL') === 0) { |
||
| 47 | $contantValue = constant($key); |
||
| 48 | if ($contantValue !== null) { |
||
| 49 | unset($config[$key]); |
||
| 50 | $config[$contantValue] = $value; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | return new Client($this->messageFactory, $this->streamFactory, $config); |
||
| 56 | } |
||
| 57 | } |
||
| 58 |