FlushCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 21
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Scout Extended.
7
 *
8
 * (c) Algolia Team <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Algolia\ScoutExtended\Console\Commands;
15
16
use Algolia\ScoutExtended\Algolia;
17
use Algolia\ScoutExtended\Helpers\SearchableFinder;
18
use Illuminate\Console\Command;
19
20
final class FlushCommand extends Command
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected $signature = 'scout:flush {searchable? : The name of the searchable}';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected $description = 'Flush the index of the the given searchable';
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 2
    public function handle(Algolia $algolia, SearchableFinder $searchableFinder): void
36
    {
37 2
        foreach ($searchableFinder->fromCommand($this) as $searchable) {
38 2
            $searchable::removeAllFromSearch();
39
40 2
            $this->output->success('All ['.$searchable.'] records have been flushed.');
41
        }
42 2
    }
43
}
44