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

FlushCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 21
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
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 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