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

TestClientFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 5 2
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