Conditions | 6 |
Paths | 7 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
13 | 4 | public static function createTransport() |
|
14 | { |
||
15 | 4 | if (class_exists(HttpClientDiscovery::class) && class_exists(MessageFactoryDiscovery::class)) { |
|
16 | try { |
||
17 | 4 | return new HttpClientTransport(HttpClientDiscovery::find(), MessageFactoryDiscovery::find()); |
|
18 | 2 | } catch (NotFoundException $e) { |
|
19 | // Do nothing |
||
20 | } |
||
21 | 2 | } |
|
22 | |||
23 | 3 | if (class_exists(Client::class)) { |
|
24 | 1 | return new Guzzle6Transport(); |
|
25 | } |
||
26 | |||
27 | 2 | if (extension_loaded('curl')) { |
|
28 | 1 | return new CurlExtensionTransport(); |
|
29 | } |
||
30 | |||
31 | 1 | throw new RuntimeException('Cannot create an HTTP transport object'); |
|
32 | } |
||
33 | } |
||
34 |