Passed
Push — master ( 3d0d87...075b69 )
by Antonio Carlos
09:13
created

Clear::fire()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 5
cts 7
cp 0.7143
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 0
crap 3.2098
1
<?php
2
3
namespace PragmaRX\Firewall\Vendor\Laravel\Artisan;
4
5
use Symfony\Component\Console\Input\InputOption;
6
7
class Clear extends Base
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'firewall:clear';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Remove all ip addresses from white and black lists.';
22
23
    /**
24
     * Clear the list.
25
     *
26
     * @return mixed
27
     */
28 1
    public function fire()
29
    {
30 1
        if (!$this->option('force')) {
31
            $this->error('This command won\'t run unless you use --force.');
32
        } else {
33 1
            if (app('firewall')->clear()) {
34 1
                $this->info('List cleared.');
35
            } else {
36
                $this->info('There were no IP addresses to be deleted.');
37
            }
38
        }
39 1
    }
40
41
    /**
42
     * Get the console command options.
43
     *
44
     * @return array
45
     */
46 24
    protected function getOptions()
47
    {
48
        return [
49 24
            ['force', null, InputOption::VALUE_NONE, 'Remove IP before adding it to the list.'],
50
        ];
51
    }
52
}
53