FlushCommand::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
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