Passed
Pull Request — master (#15)
by Serhii
06:06
created

RefreshIndex::handle()   A

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
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Matchish\ScoutElasticSearch\Jobs\Stages;
4
5
use Elasticsearch\Client;
6
use Matchish\ScoutElasticSearch\ElasticSearch\Index;
7
use Matchish\ScoutElasticSearch\ElasticSearch\Params\Indices\Refresh;
8
9
/**
10
 * @internal
11
 */
12
final class RefreshIndex
13
{
14
    /**
15
     * @var Index
16
     */
17
    private $index;
18
19
    /**
20
     * RefreshIndex constructor.
21
     * @param Index $index
22
     */
23 10
    public function __construct(Index $index)
24
    {
25 10
        $this->index = $index;
26 10
    }
27
28 9
    public function handle(Client $elasticsearch): void
29
    {
30 9
        $params = new Refresh($this->index->name());
31 9
        $elasticsearch->indices()->refresh($params->toArray());
32 9
    }
33
34 8
    public function estimate(): int
35
    {
36 8
        return 1;
37
    }
38
39 8
    public function title(): string
40
    {
41 8
        return 'Refreshing index';
42
    }
43
}
44