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

Clear   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 46
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOptions() 0 6 1
A fire() 0 12 3
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