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