ApiServiceFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 14 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