PublishMigrationCommand::getArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Consigliere\Components\Commands;
4
5
use Illuminate\Console\Command as ComponentCommand;
6
use Consigliere\Components\Migrations\Migrator;
7
use Consigliere\Components\Publishing\MigrationPublisher;
8
use Symfony\Component\Console\Input\InputArgument;
9
10 View Code Duplication
class PublishMigrationCommand extends ComponentCommand
0 ignored issues
show
Duplication introduced by
This class 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...
11
{
12
    /**
13
     * The console command name.
14
     *
15
     * @var string
16
     */
17
    protected $name = 'component:publish-migration';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = "Publish a component's migrations to the application";
25
26
    /**
27
     * Execute the console command.
28
     *
29
     * @return mixed
30
     */
31
    public function fire()
32
    {
33
        if ($name = $this->argument('component')) {
34
            $component = $this->laravel['components']->findOrFail($name);
35
36
            $this->publish($component);
37
38
            return;
39
        }
40
41
        foreach ($this->laravel['components']->enabled() as $component) {
42
            $this->publish($component);
43
        }
44
    }
45
46
    /**
47
     * Publish migration for the specified component.
48
     *
49
     * @param \Consigliere\Components\Component $component
50
     */
51
    public function publish($component)
52
    {
53
        with(new MigrationPublisher(new Migrator($component)))
54
            ->setRepository($this->laravel['components'])
55
            ->setConsole($this)
56
            ->publish();
57
    }
58
59
    /**
60
     * Get the console command arguments.
61
     *
62
     * @return array
63
     */
64
    protected function getArguments()
65
    {
66
        return [
67
            ['component', InputArgument::OPTIONAL, 'The name of component being used.'],
68
        ];
69
    }
70
}
71