Passed
Push — master ( c2cdcb...70bad3 )
by Yuichi
01:49
created

ValiableListCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 1
        }
38 1
        $headers = ['name','items'];
39 1
        $this->table($headers,$tmp);
40 1
    }
41
}
42
43