Elasticsearch7Connector::connect()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 3
cp 0
crap 2
rs 9.9666
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/elasticsearch7-adapter project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Elasticsearch7\Connector;
10
11
use Daikon\Dbal\Connector\ConnectorInterface;
12
use Daikon\Dbal\Connector\ProvidesConnector;
13
use Elasticsearch\Client;
14
use Elasticsearch\ClientBuilder;
15
16
final class Elasticsearch7Connector implements ConnectorInterface
17
{
18
    use ProvidesConnector;
19
20
    protected function connect(): Client
21
    {
22
        $connectionDsn = [
23
            'scheme' => $this->settings['scheme'],
24
            'host' => $this->settings['host'],
25
            'port' => $this->settings['port'],
26
            'user' => $this->settings['user'],
27
            'pass' => $this->settings['password']
28
        ];
29
30
        return ClientBuilder::create()
31
            ->setHosts([$connectionDsn])
32
            ->build();
33
    }
34
}
35