Test Failed
Push — master ( 6a2cd1...15b1c9 )
by Mr
01:29
created

CouchDbConnector::connect()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 32
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 8.439
c 0
b 0
f 0
cc 6
eloc 19
nc 4
nop 0
1
<?php
2
3
namespace Daikon\CouchDb\Connector;
4
5
use Daikon\Dbal\Connector\ConnectorInterface;
6
use Daikon\Dbal\Connector\ConnectorTrait;
7
use GuzzleHttp\Client;
8
9
final class CouchDbConnector implements ConnectorInterface
10
{
11
    use ConnectorTrait;
12
13
    private function connect()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
14
    {
15
        $clientOptions = [
16
            'base_uri' => sprintf(
17
                '%s://%s:%s',
18
                $this->settings['scheme'],
19
                $this->settings['host'],
20
                $this->settings['port']
21
            )
22
        ];
23
24
        if (isset($this->settings['debug'])) {
25
            $clientOptions['debug'] = $this->settings['debug'] === true;
26
        }
27
28
        if (isset($this->settings['user']) && !empty($this->settings['user'])
29
            && isset($this->settings['password']) && !empty($this->settings['password'])
30
        ) {
31
            $clientOptions['auth'] = [
32
                $this->settings['user'],
33
                $this->settings['password'],
34
                $this->settings['authentication'] ?? 'basic'
35
            ];
36
        }
37
38
        $clientOptions['headers'] = [
39
            'Accept' => 'application/json',
40
            'Content-Type' => 'application/json'
41
        ];
42
43
        return new Client($clientOptions);
44
    }
45
}
46