Conditions | 6 |
Paths | 7 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
25 | 4 | public static function createTransport(): TransportInterface |
|
26 | { |
||
27 | 4 | if (class_exists(HttpClientDiscovery::class) && class_exists(MessageFactoryDiscovery::class)) { |
|
28 | try { |
||
29 | 3 | return new HttpClientTransport(HttpClientDiscovery::find(), MessageFactoryDiscovery::find()); |
|
30 | 2 | } catch (NotFoundException $e) { |
|
31 | // Do nothing |
||
32 | } |
||
33 | } |
||
34 | |||
35 | 3 | if (class_exists(Client::class)) { |
|
36 | 1 | return new Guzzle6Transport(); |
|
37 | } |
||
38 | |||
39 | 2 | if (extension_loaded('curl')) { |
|
40 | 1 | return new CurlExtensionTransport(); |
|
41 | } |
||
42 | |||
43 | 1 | throw new RuntimeException('Cannot create an HTTP transport object'); |
|
44 | } |
||
45 | } |
||
46 |