Completed
Push — master ( ddcd57...befb63 )
by Adam
12:31
created

Destroy::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

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