FlushCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Matchish\ScoutElasticSearch\Console\Commands;
6
7
use Illuminate\Console\Command;
8
use Matchish\ScoutElasticSearch\Searchable\SearchableListFactory;
9
10
final class FlushCommand extends Command
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    protected $signature = 'scout:flush {searchable?* : The name of the searchable}';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $description = 'Flush the index of the the given searchable';
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 1
    public function handle(): void
26
    {
27 1
        $command = $this;
28
        $searchableList = collect($command->argument('searchable'))->whenEmpty(function () {
29 1
            $factory = new SearchableListFactory(app()->getNamespace(), app()->path());
0 ignored issues
show
introduced by
The method getNamespace() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
            $factory = new SearchableListFactory(app()->/** @scrutinizer ignore-call */ getNamespace(), app()->path());
Loading history...
introduced by
The method path() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
            $factory = new SearchableListFactory(app()->getNamespace(), app()->/** @scrutinizer ignore-call */ path());
Loading history...
30
31 1
            return $factory->make();
32 1
        });
33
        $searchableList->each(function ($searchable) {
34 1
            $searchable::removeAllFromSearch();
35 1
            $doneMessage = trans('scout::flush.done', [
36 1
                'searchable' => $searchable,
37
            ]);
38 1
            $this->output->success($doneMessage);
39 1
        });
40 1
    }
41
}
42