Completed
Push — master ( 6a2de0...36e020 )
by Márk
37:44 queued 30:09
created

CurlFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 34
ccs 7
cts 8
cp 0.875
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createClient() 0 8 2
1
<?php
2
3
namespace Http\HttplugBundle\ClientFactory;
4
5
use Http\Client\Curl\Client;
6
use Http\Message\MessageFactory;
7
use Http\Message\StreamFactory;
8
9
/**
10
 * @author Tobias Nyholm <[email protected]>
11
 */
12
class CurlFactory implements ClientFactory
13
{
14
    /**
15
     * @var MessageFactory
16
     */
17
    private $messageFactory;
18
19
    /**
20
     * @var StreamFactory
21
     */
22
    private $streamFactory;
23
24
    /**
25
     * @param MessageFactory $messageFactory
26
     * @param StreamFactory  $streamFactory
27
     */
28 1
    public function __construct(MessageFactory $messageFactory, StreamFactory $streamFactory)
29
    {
30 1
        $this->messageFactory = $messageFactory;
31 1
        $this->streamFactory = $streamFactory;
32 1
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
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
        return new Client($this->messageFactory, $this->streamFactory, $config);
44
    }
45
}
46