Total Complexity | 4 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
16 | final class CreateWriteIndex |
||
17 | { |
||
18 | /** |
||
19 | * @var Model |
||
20 | */ |
||
21 | private $searchable; |
||
22 | /** |
||
23 | * @var Index |
||
24 | */ |
||
25 | private $index; |
||
26 | |||
27 | /** |
||
28 | * @param Model $searchable |
||
29 | * @param Index $index |
||
30 | */ |
||
31 | 10 | public function __construct(Model $searchable, Index $index) |
|
35 | 10 | } |
|
36 | |||
37 | 9 | public function handle(Client $elasticsearch): void |
|
38 | { |
||
39 | /** @var Searchable $searchable */ |
||
40 | 9 | $searchable = $this->searchable; |
|
41 | 9 | $this->index->addAlias(new WriteAlias(new DefaultAlias($searchable->searchableAs()))); |
|
42 | |||
43 | 9 | $params = new Create( |
|
44 | 9 | $this->index->name(), |
|
45 | 9 | $this->index->config() |
|
46 | ); |
||
47 | |||
48 | 9 | $elasticsearch->indices()->create($params->toArray()); |
|
49 | 9 | } |
|
50 | |||
51 | 8 | public function title(): string |
|
52 | { |
||
53 | 8 | return 'Create write index'; |
|
54 | } |
||
55 | |||
56 | 8 | public function estimate(): int |
|
59 | } |
||
60 | } |
||
61 |