Passed
Push — feature/initial-implementation ( f3915b...fbd338 )
by Fike
02:22
created

TestClientFactory::getClient()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Test\Support;
6
7
use AmaTeam\ElasticSearch\API\ClientFactoryInterface;
8
use Elasticsearch\Client;
9
use Elasticsearch\ClientBuilder;
10
11
class TestClientFactory implements ClientFactoryInterface
12
{
13
    public function getClient(): Client
14
    {
15
        $connectionString = getenv('ELASTICSEARCH_CONTACT_POINTS') ?: 'localhost:9200';
16
        $contactPoints = array_filter(array_map('trim', explode(',', $connectionString)));
17
        return ClientBuilder::create()->setHosts($contactPoints)->build();
18
    }
19
}
20