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