Completed
Push — master ( f8c9ff...80eb7e )
by Adam
03:35
created

Destroy::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 0
crap 6
1
<?php
2
3
namespace BestServedCold\LaravelZendSearch\Laravel\Console;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Config\Repository;
7
use Symfony\Component\Console\Output\NullOutput;
8
use Illuminate\Support\Facades\File;
9
use Illuminate\Support\Facades\App;
10
11
/**
12
 * Class ClearCommand
13
 * @package BestServedCold\LaravelZendSearch\Laravel\Console
14
 */
15
class Destroy extends Command
16
{
17
    protected $name = 'search:destroy';
18
    protected $description = 'Destroys the search index.';
19
20
    public function handle()
21
    {
22
        $config = App::make(Repository::class);
23
24
        $indexPath = $config->get('search.index.path');
25
26
        $this->info('Destroying the search index.');
27
28
        if (File::isDirectory($indexPath)) {
29
            File::deleteDirectory($indexPath);
30
            $this->info('Search index is destroyed.');
31
        } else {
32
            $this->comment('There was nothing to destroy?  Try a rebuild.');
33
        }
34
    }
35
}
36