Completed
Push — master ( e8377f...e76f82 )
by Adam
02:57
created

DestroyCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 23
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fire() 0 17 3
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 DestroyCommand extends Command
16
{
17
    protected $name = 'search:destroy';
18
    protected $description = 'Destroys the search index storage.';
19
20
    public function fire()
21
    {
22
        if (!$this->option('verbose')) {
23
            $this->output = new NullOutput;
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Symfony\Component\Console\Output\NullOutput() of type object<Symfony\Component...sole\Output\NullOutput> is incompatible with the declared type object<Illuminate\Console\OutputStyle> of property $output.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
        }
25
26
        $config = App::make(Repository::class);
27
28
        $this->info('Clearing search index');
29
30
        if (File::isDirectory($indexPath = $config->get('search.index.path'))) {
31
            File::deleteDirectory($indexPath);
32
            $this->info('Search index is cleared.');
33
        } else {
34
            $this->comment('There was nothing to clear.');
35
        }
36
    }
37
}
38