AdapterFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

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