Code Duplication    Length = 59-64 lines in 2 locations

src/Console/Commands/InstallCommand.php 1 location

@@ 7-65 (lines=59) @@
4
5
use Illuminate\Contracts\Container\Container;
6
7
class InstallCommand extends AbstractInitializeCommand
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'app:install';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Install the application according to current environment';
22
23
    /**
24
     * Create a new command instance.
25
     *
26
     * @param  Illuminate\Contracts\Container\Container  $container
27
     * @return void
28
     */
29
    public function __construct(Container $container)
30
    {
31
        $this->signature = 'app:install
32
                            {--root : Run commands which requires root privileges}
33
                            {--o|options=* : Run commands for custom options'.$this->getOptionsConfig($container).'}';
34
35
        parent::__construct();
36
    }
37
38
    /**
39
     * Returns instance of Install class which defines initializing runner chain.
40
     *
41
     * {@inheritdoc}
42
     */
43
    protected function getInitializerInstance(Container $container)
44
    {
45
        return $container->make('app.installer');
46
    }
47
48
    protected function title(): string
49
    {
50
        return 'Application installation';
51
    }
52
53
    protected function getOptionsConfig(Container $container)
54
    {
55
        $config = $container->make('config');
56
        $env = $config->get($config->get('initializer.env_config_key'));
57
        $options = $config->get($config->get('initializer.options.'.$env.'.install'));
58
59
        $options = array_keys($options);
60
61
        if (count($options) > 0) {
62
            return '. Allowed options:['.implode(', ', $options).']';
63
        }
64
    }
65
}
66

src/Console/Commands/UpdateCommand.php 1 location

@@ 7-70 (lines=64) @@
4
5
use Illuminate\Contracts\Container\Container;
6
7
class UpdateCommand extends AbstractInitializeCommand
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'app:update';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Update the application according to current environment';
22
23
    /**
24
     * Create a new command instance.
25
     *
26
     * @param  Illuminate\Contracts\Container\Container  $container
27
     * @return void
28
     */
29
    public function __construct(Container $container)
30
    {
31
        $this->signature = 'app:update
32
                            {--root : Run commands which requires root privileges}
33
                            {--o|options=* : Run commands for custom options'.$this->getOptionsConfig($container).'}';
34
35
        parent::__construct();
36
    }
37
38
    /**
39
     * Returns instance of Update class which defines initializing runner chain.
40
     *
41
     * {@inheritdoc}
42
     */
43
    protected function getInitializerInstance(Container $container)
44
    {
45
        return $container->make('app.updater');
46
    }
47
48
    protected function title(): string
49
    {
50
        return 'Application update';
51
    }
52
53
    /**
54
     * Returns allowed options.
55
     *
56
     * @return string
57
     */
58
    protected function getOptionsConfig(Container $container)
59
    {
60
        $config = $container->make('config');
61
        $env = $config->get($config->get('initializer.env_config_key'));
62
        $options = $config->get($config->get('initializer.options.'.$env.'.update'));
63
64
        $options = array_keys($options);
65
66
        if (count($options) > 0) {
67
            return '. Allowed options:['.implode(', ', $options).']';
68
        }
69
    }
70
}
71