ApiService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createIndex() 0 4 1
A createType() 0 4 1
A updateType() 0 10 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