Completed
Push — master ( 880a30...6b3c1e )
by Fumio
02:31
created

AddonStatusCommand::handle()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 4.0313

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 23
ccs 14
cts 16
cp 0.875
rs 8.7972
cc 4
eloc 12
nc 8
nop 2
crap 4.0313
1
<?php
2
3
namespace Jumilla\Addomnipot\Laravel\Console;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Jumilla\Addomnipot\Laravel\Environment as AddonEnvironment;
8
9
class AddonStatusCommand extends Command
10
{
11
    /**
12
     * The console command signature.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'addon:status';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'List up addon information';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @return mixed
29
     */
30 1
    public function handle(Filesystem $filesystem, AddonEnvironment $env)
31
    {
32
        // make addons/
33 1
        $addonsDirectory = $env->path();
34 1
        if (!$filesystem->exists($addonsDirectory)) {
35
            $filesystem->makeDirectory($addonsDirectory);
36
        }
37
38
        // copy app/config/addon.php
39 1
        $addonConfigSourceFile = __DIR__.'/../../config/addon.php';
40 1
        $addonConfigFile = $this->laravel['path.config'].'/addon.php';
41 1
        if (!$filesystem->exists($addonConfigFile)) {
42 1
            $filesystem->copy($addonConfigSourceFile, $addonConfigFile);
43
44 1
            $this->info('make config: '.$addonConfigFile);
45 1
        }
46
47
        // show lists
48 1
        $addons = $env->addons();
49 1
        foreach ($addons as $addon) {
50 1
            $this->dump($addon);
51 1
        }
52 1
    }
53
54 1
    protected function dump($addon)
55
    {
56 1
        $this->line($addon->name());
57 1
    }
58
}
59