DeleteCommand::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 11
rs 10
cc 1
nc 1
nop 0
1
<?php namespace Nord\Lumen\Elasticsearch\Console;
2
3
use Nord\Lumen\Elasticsearch\IndexNamePrefixer;
4
5
class DeleteCommand extends AbstractCommand
6
{
7
8
    /**
9
     * The name and signature of the console command.
10
     *
11
     * @var string
12
     */
13
    protected $signature = 'elastic:index:delete {index}';
14
15
    /**
16
     * The console command description.
17
     *
18
     * @var string
19
     */
20
    protected $description = 'Deletes an Elasticsearch index.';
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function handle()
26
    {
27
        $index = IndexNamePrefixer::getPrefixedIndexName((string)$this->argument('index'));
28
29
        $this->info(sprintf("Deleting index '%s' ...", $index));
30
31
        $this->elasticsearchService->indices()->delete(['index' => $index]);
32
33
        $this->info(sprintf("Index '%s' deleted.", $index));
34
35
        return 0;
36
    }
37
}
38