| Conditions | 5 |
| Paths | 3 |
| Total Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function handle(): int |
||
| 32 | { |
||
| 33 | $indexName = $this->argument('index-name'); |
||
| 34 | |||
| 35 | if ($indexName === null || |
||
| 36 | !is_string($indexName) || |
||
| 37 | mb_strlen($indexName) === 0 |
||
| 38 | ) { |
||
| 39 | $this->output->writeln( |
||
| 40 | '<error>Argument index-name must be a non empty string.</error>' |
||
| 41 | ); |
||
| 42 | |||
| 43 | return self::FAILURE; |
||
| 44 | } |
||
| 45 | |||
| 46 | if ($this->client->indices()->exists([ |
||
| 47 | 'index' => $indexName, |
||
| 48 | ])) { |
||
| 49 | $this->output->writeln( |
||
| 50 | sprintf( |
||
| 51 | '<info>Index %s exists.</info>', |
||
| 52 | $indexName |
||
| 53 | ) |
||
| 54 | ); |
||
| 55 | |||
| 56 | return self::SUCCESS; |
||
| 57 | } else { |
||
| 58 | $this->output->writeln( |
||
| 59 | sprintf( |
||
| 60 | '<comment>Index %s doesn\'t exists.</comment>', |
||
| 61 | $indexName |
||
| 62 | ) |
||
| 63 | ); |
||
| 64 | |||
| 65 | return self::SUCCESS; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 |