| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | 14 | public function handle(Client $elasticsearch): void |
|
| 36 | { |
||
| 37 | 14 | $source = $this->source; |
|
| 38 | 14 | $params = Get::anyIndex($source->searchableAs()); |
|
| 39 | 14 | $response = $elasticsearch->indices()->getAlias($params->toArray()); |
|
| 40 | |||
| 41 | 14 | $params = new Update(); |
|
| 42 | 14 | foreach ($response as $indexName => $alias) { |
|
| 43 | 14 | if ($indexName != $this->index->name()) { |
|
| 44 | 2 | $params->removeIndex((string) $indexName); |
|
| 45 | } else { |
||
| 46 | 14 | $params->add((string) $indexName, $source->searchableAs()); |
|
| 47 | } |
||
| 48 | } |
||
| 49 | 14 | $elasticsearch->indices()->updateAliases($params->toArray()); |
|
| 50 | 14 | } |
|
| 62 |