Passed
Push — master ( 6bfad1...b9baef )
by Antonio Carlos
03:31
created

Clear   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 43
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fire() 0 9 3
A getOptions() 0 4 1
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
     * Execute the console command.
25
     *
26
     * @return mixed
27
     */
28
    public function fire()
29
    {
30
        if (!$this->option('force')) {
31
            $this->error('This command won\'t run unless you use --force.');
32
        } else {
33
            if ($this->laravel->firewall->clear()) {
0 ignored issues
show
Bug introduced by
Accessing firewall on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
34
                $this->info('List cleared.');
35
            } else {
36
                $this->info('There were no IP addresses to be deleted.');
37
            }
38
        }
39
    }
40
41
    /**
42
     * Get the console command options.
43
     *
44
     * @return array
45
     */
46
    protected function getOptions()
47
    {
48
        return [
49
            ['force', null, InputOption::VALUE_NONE, 'Remove IP before adding it to the list.'],
50
        ];
51
    }
52
}
53