Issues (17)

src/Console/Commands/FlushCommand.php (2 issues)

Severity
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
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...
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