Passed
Branch master (ecb760)
by Antonio Carlos
05:12
created

Report::fire()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 6.4268

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 7
cts 15
cp 0.4667
rs 8.9197
c 0
b 0
f 0
cc 4
eloc 14
nc 5
nop 0
crap 6.4268
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 38
    public function __construct()
27
    {
28 38
        parent::__construct();
29 38
    }
30
31
    /**
32
     * List all ips from all lists.
33
     *
34
     * @return mixed
35
     */
36 1
    public function fire()
37
    {
38 1
        $table = new Table($this->output);
39
40 1
        $list = [];
41
42 1
        foreach (app('firewall')->report() as $ip) {
43
            $list[] = [
44
                $ip['ip_address'],
45
                $ip['whitelisted'] == false
46
                    ? ''
47
                    : '    X    ',
48
                $ip['whitelisted'] == false
49
                    ? '    X    '
50
                    : '',
51
            ];
52
        }
53
54 1
        $table->setHeaders(['IP Address', 'Whitelist', 'Blacklist'])->setRows($list);
55
56 1
        $table->render();
57 1
    }
58
}
59