| Conditions | 6 |
| Paths | 8 |
| Total Lines | 16 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 14 | public function handle(Client $elasticsearch): void |
|
| 30 | { |
||
| 31 | 14 | $source = $this->source; |
|
| 32 | 14 | $params = GetAliasParams::anyIndex($source->searchableAs()); |
|
| 33 | try { |
||
| 34 | /** @var array $response */ |
||
| 35 | 14 | $response = $elasticsearch->indices()->getAlias($params->toArray()); |
|
| 36 | 13 | } catch (Missing404Exception $e) { |
|
| 37 | 13 | $response = []; |
|
| 38 | } |
||
| 39 | 14 | foreach ($response as $indexName => $data) { |
|
| 40 | 2 | foreach ($data['aliases'] as $alias => $config) { |
|
| 41 | 2 | if (array_key_exists('is_write_index', $config) && $config['is_write_index']) { |
|
| 42 | 1 | $params = new DeleteIndexParams((string) $indexName); |
|
| 43 | 1 | $elasticsearch->indices()->delete($params->toArray()); |
|
| 44 | 1 | continue 2; |
|
| 45 | } |
||
| 60 |