DumpCommand::dump()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Consigliere\Components\Commands;
4
5
use Illuminate\Console\Command as ComponentCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
8
class DumpCommand extends ComponentCommand
9
{
10
    /**
11
     * The console command name.
12
     *
13
     * @var string
14
     */
15
    protected $name = 'component:dump';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Dump-autoload the specified component or for all component.';
23
24
    /**
25
     * Execute the console command.
26
     *
27
     * @return mixed
28
     */
29 View Code Duplication
    public function fire()
0 ignored issues
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...
30
    {
31
        $this->info('Generating optimized autoload components.');
32
33
        if ($component = $this->argument('component')) {
34
            $this->dump($component);
35
        } else {
36
            foreach ($this->laravel['components']->all() as $component) {
37
                $this->dump($component->getStudlyName());
38
            }
39
        }
40
    }
41
42
    public function dump($component)
43
    {
44
        $component = $this->laravel['components']->findOrFail($component);
45
46
        $this->line("<comment>Running for component</comment>: {$component}");
47
48
        chdir($component->getPath());
49
50
        passthru('composer dump -o -n -q');
51
    }
52
53
    /**
54
     * Get the console command arguments.
55
     *
56
     * @return array
57
     */
58
    protected function getArguments()
59
    {
60
        return [
61
            ['component', InputArgument::OPTIONAL, 'Component name.'],
62
        ];
63
    }
64
}
65