Completed
Push — master ( e09f8c...50fa0d )
by Fumio
10:35
created

AddonStatusCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 93.75%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 3
dl 0
loc 50
ccs 15
cts 16
cp 0.9375
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dump() 0 4 1
B handle() 0 23 4
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
        }
46
47
        // show lists
48 1
        $addons = $env->addons();
49 1
        foreach ($addons as $addon) {
50 1
            $this->dump($addon);
51
        }
52 1
    }
53
54 1
    protected function dump($addon)
55
    {
56 1
        $this->line($addon->name());
57 1
    }
58
}
59