Passed
Branch master (70bad3)
by Yuichi
03:23 queued 01:38
created

ValiableListCommand::fire()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 0
crap 3
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