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

Report::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PragmaRX\Firewall\Vendor\Laravel\Artisan;
4
5
use Symfony\Component\Console\Helper\Table;
6
7
class Report extends Base
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'firewall:list';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'List all IP address, white and blacklisted.';
22
23
    /**
24
     * Create a new command instance.
25
     */
26
    public function __construct()
27
    {
28
        parent::__construct();
29
    }
30
31
    /**
32
     * Execute the console command.
33
     *
34
     * @return mixed
35
     */
36
    public function fire()
37
    {
38
        $table = new Table($this->output);
39
40
        $list = [];
41
42
        foreach ($this->laravel->firewall->report() as $ip) {
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...
43
            $list[] = [
44
                $ip['ip_address'],
45
                $ip['whitelisted'] == false
46
                    ? ''
47
                    : '    X    ',
48
                $ip['whitelisted'] == false
49
                    ? '    X    '
50
                    : '',
51
            ];
52
        }
53
54
        $table->setHeaders(['IP Address', 'Whitelist', 'Blacklist'])->setRows($list);
55
56
        $table->render();
57
    }
58
}
59