Rebuild   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 41
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 18 2
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
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * Class RebuildCommand
15
 * @package BestServedCold\LaravelZendSearch\Laravel\Console
16
 */
17
class Rebuild extends Command
18
{
19
    /**
20
     * @var string $name
21
     */
22
    protected $name = 'search:rebuild';
23
24
    /**
25
     * @var string $description
26
     */
27
    protected $description = 'Rebuild the search index';
28
29
    /**
30
     * @var OutputInterface
31
     */
32
    protected $output;
33
34
    /**
35
     * Handle
36
     *
37
     * @return void
38
     */
39 3
    public function handle()
40
    {
41 3
        if (!$this->option('verbose')) {
42 1
            $this->output = new NullOutput;
43 1
        }
44
45 3
        $rebuild = new RebuildModels(
46 3
            new ProgressBar($this->getOutput()),
47 3
            App::make(Store::class),
48 3
            $this->output
49 3
        );
50
51 3
        $this->call('search:destroy', $this->getArguments());
52 3
        $rebuild->rebuild();
53
54 3
        $this->call('search:optimise', $this->getArguments());
55 3
        $this->info(PHP_EOL.'Search engine rebuild complete.');
56 3
    }
57
}
58