Code Duplication    Length = 60-66 lines in 2 locations

src/Console/Commands/InstallCommand.php 1 location

@@ 7-66 (lines=60) @@
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
        $options = $config->get($config->get('initializer.options.install'));
57
58
        $options = array_keys($options);
59
60
        if(count($options) > 0) {
61
            return '. Allowed options:[' . implode(', ', $options) . ']';
62
        }
63
64
        return;
65
    }
66
}
67

src/Console/Commands/UpdateCommand.php 1 location

@@ 7-72 (lines=66) @@
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
    /**
40
     * Returns instance of Update class which defines initializing runner chain.
41
     *
42
     * {@inheritdoc}
43
     */
44
    protected function getInitializerInstance(Container $container)
45
    {
46
        return $container->make('app.updater');
47
    }
48
49
    protected function title(): string
50
    {
51
        return 'Application update';
52
    }
53
54
    /**
55
     * Returns allowed options.
56
     *
57
     * @return string
58
     */
59
    protected function getOptionsConfig(Container $container)
60
    {
61
        $config = $container->make('config');
62
        $options = $config->get($config->get('initializer.options.update'));
63
64
        $options = array_keys($options);
65
66
        if(count($options) > 0) {
67
            return '. Allowed options:[' . implode(', ', $options) . ']';
68
        }
69
70
        return;
71
    }
72
}
73