Completed
Push — master ( 5f5045...66f0fe )
by Alessandro
07:07
created

Factory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 6
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createTransport() 0 20 6
1
<?php
2
3
namespace Fazland\SkebbyRestClient\Transport;
4
5
use Fazland\SkebbyRestClient\Exception\RuntimeException;
6
use GuzzleHttp\Client;
7
use Http\Discovery\Exception\NotFoundException;
8
use Http\Discovery\HttpClientDiscovery;
9
use Http\Discovery\MessageFactoryDiscovery;
10
11
class Factory
12
{
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