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