ApiService::createType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Pgs\ElasticOM\ElasticApi;
4
5
class ApiService
6
{
7
    /** @var ElasticApi */
8
    protected $elasticApi;
9
10
    /** @var string */
11
    protected $index;
12
13 3
    public function __construct(ElasticApi $elasticApi, string $index)
14
    {
15 3
        $this->elasticApi = $elasticApi;
16 3
        $this->index = $index;
17 3
    }
18
19 2
    public function createIndex()
20
    {
21 2
        $this->elasticApi->createIndex($this->index);
22 2
    }
23
24 2
    public function createType(string $type)
25
    {
26 2
        $this->elasticApi->createType($this->index, $type);
27 2
    }
28
29 1
    public function updateType(string $type)
30
    {
31 1
        $this->elasticApi->createIndex('tmp'.$this->index);
32 1
        $this->elasticApi->reindex($this->index, 'tmp'.$this->index);
33 1
        $this->elasticApi->removeIndex($this->index);
34 1
        $this->createIndex();
35 1
        $this->createType($type);
36 1
        $this->elasticApi->reindex('tmp'.$this->index, $this->index);
37 1
        $this->elasticApi->removeIndex('tmp'.$this->index);
38 1
    }
39
}
40