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

Rebuild::getModels()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 4
nc 3
nop 0
crap 20
1
<?php
2
3
namespace BestServedCold\LaravelZendSearch\Laravel\Console;
4
5
use BestServedCold\LaravelZendSearch\Laravel\RebuildModels;
6
use BestServedCold\LaravelZendSearch\Laravel\Store;
7
use Illuminate\Console\Command;
8
use Illuminate\Support\Facades\App;
9
use Symfony\Component\Console\Helper\ProgressBar;
10
use Symfony\Component\Console\Output\NullOutput;
11
12
/**
13
 * Class RebuildCommand
14
 * @package BestServedCold\LaravelZendSearch\Laravel\Console
15
 */
16
class Rebuild extends Command
17
{
18
    protected $name = 'search:rebuild';
19
    protected $description = 'Rebuild the search index';
20
21
    /**
22
     * @return void
23
     */
24 3
    public function handle()
25
    {
26 3
        if (!$this->option('verbose')) {
27 1
            $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...
28 1
        }
29
30 3
        $rebuild = new RebuildModels(
31 3
            new ProgressBar($this->getOutput()),
32 3
            App::make(Store::class),
33 3
            $this->output
34 3
        );
35
36 3
        $this->call('search:destroy', $this->getArguments());
37 3
        $rebuild->rebuild();
38
39 3
        $this->call('search:optimise', $this->getArguments());
40 3
        $this->info(PHP_EOL . 'Search engine rebuild complete.');
41 3
    }
42
}
43