ApiServiceFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Pgs\ElasticOM\ElasticApi;
4
5
use Elasticsearch\ClientBuilder;
6
use Pgs\ElasticOM\JsonSerializer;
7
8
class ApiServiceFactory
9
{
10 1
    public static function create(string $host, string $port, string $index): ApiService
11
    {
12 1
        $client = ClientBuilder::create()
13 1
            ->setSerializer(new JsonSerializer())
14 1
            ->setHosts(["$host:$port"])
15 1
            ->build();
16
17 1
        $elasticApi = new ElasticApi($client);
18
19 1
        return new ApiService(
20
            $elasticApi,
21
            $index
22
        );
23
    }
24
}
25