Total Complexity | 6 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 92.86% |
Changes | 0 |
1 | <?php |
||
6 | class DeleteIndex extends AbstractMigration |
||
7 | { |
||
8 | /** |
||
9 | * Get validation rules |
||
10 | * |
||
11 | * @return array |
||
12 | */ |
||
13 | 5 | public function getValidationRules(): array |
|
14 | { |
||
15 | return [ |
||
16 | 5 | 'index' => 'required|string' |
|
17 | ]; |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * Pre check |
||
22 | * |
||
23 | * @param Client $esClient |
||
24 | * @param array $params |
||
25 | * |
||
26 | * @throws \Exception |
||
27 | */ |
||
28 | 4 | public function preCheck(Client $esClient, array $params) |
|
29 | { |
||
30 | 4 | $index = $params['index']; |
|
31 | |||
32 | 4 | if (!$esClient->indices()->exists(['index' => $params['index']])) { |
|
33 | 1 | throw new \Exception(sprintf("Index not exist: %s", $index)); |
|
34 | } |
||
35 | 3 | } |
|
36 | |||
37 | /** |
||
38 | * Start migration |
||
39 | * |
||
40 | * @param Client $esClient |
||
41 | * @param array $params |
||
42 | */ |
||
43 | 3 | public function startMigration(Client $esClient, array $params) |
|
44 | { |
||
45 | 3 | $esClient->indices()->delete($params); |
|
46 | 3 | } |
|
47 | |||
48 | /** |
||
49 | * Post check |
||
50 | * |
||
51 | * @param Client $esClient |
||
52 | * @param array $params |
||
53 | * |
||
54 | * @throws \Exception |
||
55 | */ |
||
56 | 3 | public function postCheck(Client $esClient, array $params) |
|
62 | } |
||
63 | 3 | } |
|
64 | } |
||
65 |