Completed
Pull Request — master (#322)
by Mathieu
03:43
created

DumpCommand::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 12
1
<?php
2
3
namespace Nwidart\Modules\Commands;
4
5
use Illuminate\Console\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
8
class DumpCommand extends Command
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'module:dump';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Dump-autoload the specified module or for all module.';
23
24
    /**
25
     * Execute the console command.
26
     */
27 View Code Duplication
    public function handle()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $this->info('Generating optimized autoload modules.');
30
31
        if ($module = $this->argument('module')) {
32
            $this->dump($module);
33
        } else {
34
            foreach ($this->laravel['modules']->all() as $module) {
35
                $this->dump($module->getStudlyName());
36
            }
37
        }
38
    }
39
40
    public function dump($module)
41
    {
42
        $module = $this->laravel['modules']->findOrFail($module);
43
44
        $this->line("<comment>Running for module</comment>: {$module}");
45
46
        chdir($module->getPath());
47
48
        passthru('composer dump -o -n -q');
49
    }
50
51
    /**
52
     * Get the console command arguments.
53
     *
54
     * @return array
55
     */
56 56
    protected function getArguments()
57
    {
58
        return array(
59 56
            array('module', InputArgument::OPTIONAL, 'Module name.'),
60
        );
61
    }
62
}
63