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

Destroy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 21
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 2
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