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

Report   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 52
ccs 10
cts 18
cp 0.5556
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B fire() 0 22 4
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