Completed
Pull Request — master (#12)
by Adam
05:00 queued 01:43
created

Destroy   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 33
ccs 7
cts 10
cp 0.7
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
    /**
17
     * @var string $name
18
     */
19
    protected $name = 'search:destroy';
20
21
    /**
22
     * @var string $description
23
     */
24
    protected $description = 'Destroys the search index.';
25
26
    /**
27
     * Handle
28
     *
29
     * @return void
30
     */
31 1
    public function handle()
32
    {
33 1
        $config = App::make(Repository::class);
34
35 1
        $indexPath = $config->get('search.index.path');
36
37 1
        $this->info('Destroying the search index.');
38
39 1
        if (File::isDirectory($indexPath)) {
40
            File::deleteDirectory($indexPath);
41
            $this->info('Search index is destroyed.');
42
        } else {
43 1
            $this->comment('There was nothing to destroy?  Try a rebuild.');
44
        }
45 1
    }
46
}
47