Completed
Push — master ( 6a987b...aa82ab )
by Nuno
23:32 queued 20:14
created

FlushCommand::handle()   A

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 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
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 Laravel\Scout\Searchable;
17
use Illuminate\Console\Command;
18
use Algolia\ScoutExtended\Algolia;
19
use Algolia\ScoutExtended\Helpers\SearchableFinder;
20
21
final class FlushCommand extends Command
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected $signature = 'scout:flush {searchable? : The name of the searchable}';
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected $description = 'Flush the index of the the given searchable';
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 2
    public function handle(Algolia $algolia, SearchableFinder $searchableFinder): void
37
    {
38 2
        foreach ($searchableFinder->fromCommand($this) as $searchable) {
39 2
            $searchable::removeAllFromSearch();
40
41 2
            $this->output->success('All ['.$searchable.'] records have been flushed.');
42
        }
43 2
    }
44
}
45