ValiableListCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
namespace Sonar\Valiable\Console;
3
4
use Illuminate\Console\Command;
5
6
use Sonar\Valiable\Valiable;
7
8
class ValiableListCommand extends Command
9
{
10
    protected $name = 'valiable:list';
11
    protected $description = 'show valiable list';
12
    protected $valiable;
13
    protected $filesystem;
14
15 2
    public function __construct(Valiable $valiable)
16
    {
17 2
        $this->valiable = $valiable;
18 2
        parent::__construct();
19 2
    }
20
21 1
    public function handle()
22
    {
23 1
        return $this->fire();
24
    }
25
26 1
    public function fire()
27
    {
28 1
        $names = $this->valiable->getNames();
29 1
        $tmp = [];
30 1
        $len = 0;
31 1
        foreach ( $names as $name ) {
32 1
            $len = strlen($name) > $len ? strlen($name) : $len;
33 1
            $tmp[] = [
34 1
                'name' => $name,
35 1
                'items' => serialize($this->valiable->get($name)),
36
            ];
37
        }
38 1
        $headers = ['name','items'];
39 1
        $this->table($headers,$tmp);
40 1
    }
41
}
42
43