Completed
Push — master ( 192d1a...fbc00d )
by Fumio
02:39
created

AddonListCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 54
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
B handle() 0 23 4
A dump() 0 6 1
1
<?php
2
3
namespace Jumilla\Addomnipot\Laravel\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Jumilla\Addomnipot\Laravel\Environment as AddonEnvironment;
8
9
class AddonListCommand extends Command
10
{
11
    use Functions;
12
13
    /**
14
     * The console command signature.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'addon:list';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'List up addon information';
26
27
    /**
28
     * Execute the console command.
29
     *
30
     * @return mixed
31
     */
32
    public function handle(Filesystem $filesystem, AddonEnvironment $env)
33
    {
34
        // make addons/
35
        $addonsDirectory = $env->path();
36
        if (!$filesystem->exists($addonsDirectory)) {
37
            $filesystem->makeDirectory($addonsDirectory);
38
        }
39
40
        // copy app/config/addon.php
41
        $addonConfigSourceFile = __DIR__.'/../../config/addon.php';
42
        $addonConfigFile = $this->laravel['path.config'].'/addon.php';
43
        if (!$filesystem->exists($addonConfigFile)) {
44
            $filesystem->copy($addonConfigSourceFile, $addonConfigFile);
45
46
            $this->info('make config: '.$addonConfigFile);
47
        }
48
49
        // show lists
50
        $addons = $env->addons();
51
        foreach ($addons as $addon) {
52
            $this->dump($addon);
53
        }
54
    }
55
56
    protected function dump($addon)
57
    {
58
        $path = $addon->relativePath($this->laravel);
59
60
        $this->line("<info>{$addon->name()}</info> {$path}");
61
    }
62
}
63