Guzzle5Factory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 26
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createClient() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Http\HttplugBundle\ClientFactory;
6
7
use GuzzleHttp\Client;
8
use Http\Adapter\Guzzle5\Client as Adapter;
9
use Http\Message\MessageFactory;
10
11
/**
12
 * @author Tobias Nyholm <[email protected]>
13
 */
14
class Guzzle5Factory implements ClientFactory
15
{
16
    /**
17
     * @var MessageFactory
18
     */
19
    private $messageFactory;
20
21
    public function __construct(MessageFactory $messageFactory)
22
    {
23
        $this->messageFactory = $messageFactory;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function createClient(array $config = [])
30
    {
31
        if (!class_exists('Http\Adapter\Guzzle5\Client')) {
32
            throw new \LogicException('To use the Guzzle5 adapter you need to install the "php-http/guzzle5-adapter" package.');
33
        }
34
35
        $client = new Client($config);
36
37
        return new Adapter($client, $this->messageFactory);
38
    }
39
}
40