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

Destroy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 21
ccs 10
cts 10
cp 1
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 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