Completed
Push — master ( e01909...ccba9b )
by Alexandr
05:00
created

LarrockInstallCommand::handle()   D

Complexity

Conditions 13
Paths 259

Size

Total Lines 60
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 60
rs 4.6566
cc 13
eloc 37
nc 259
nop 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Larrock\Core\Commands;
4
5
use Illuminate\Console\Command;
6
7
class LarrockInstallCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'larrock:install {--fast= : fast install}';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Install LarrockCMS';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return mixed
27
     */
28
    public function handle()
29
    {
30
        $fast = $this->option('fast');
31
32
        $this->line('=== Install LarrockCMS ===');
33
34
        if(env('DB_DATABASE') === 'homestead' || env('DB_USERNAME') === 'homestead' || env('DB_PASSWORD') === 'secret') {
35
            $this->line('Параметры подключения к БД в .env-файле:');
36
            $this->line('DB_DATABASE=' . env('DB_DATABASE'));
37
            $this->line('DB_USERNAME=' . env('DB_USERNAME'));
38
            $this->line('DB_PASSWORD=' . env('DB_PASSWORD'));
39
            if ( !$this->confirm('Данные для доступа к БД верны?')) {
40
                $this->error('Установка завершена некорректно. Пожалуйста, установите правильные данные для 
41
                доступа к БД и выполните команду php artisan larrock:install');
42
                return FALSE;
43
            }
44
        }
45
46
        if($fast){
47
            $this->call('larrock:updateEnv');
48
            $this->call('larrock:renamePublicDirectory');
49
            $this->call('larrock:updateVendorConfig');
50
            $this->call('vendor:publish');
51
            $this->call('migrate');
52
            $this->call('larrock:addAdmin');
53
            $this->call('larrock:assets');
54
        }else{
55
            if ($this->confirm('Шаг 1/7. Обновить .env? (larrock:updateEnv)')) {
56
                $this->call('larrock:updateEnv');
57
            }
58
59
            if ($this->confirm('Шаг 2/7. Сменить директорию "public" на "public_html"? (larrock:renamePublicDirectory)')) {
60
                $this->call('larrock:renamePublicDirectory');
61
            }
62
63
            if ($this->confirm('Шаг 3/7. Обновить конфиги зависимостей? (larrock:updateVendorConfig)')) {
64
                $this->call('larrock:updateVendorConfig');
65
            }
66
67
            if ($this->confirm('Шаг 4/7. Опубликовать ресурсы (vendor:publish)?')) {
68
                $this->call('vendor:publish');
69
            }
70
71
            if ($this->confirm('Шаг 5/7. Выполнить миграции БД (migrate)?')) {
72
                $this->call('migrate');
73
            }
74
75
            if ($this->confirm('Шаг 6/7. Добавить пользователя администратора? (larrock:addAdmin)')) {
76
                $this->call('larrock:addAdmin');
77
            }
78
79
            if ($this->confirm('Шаг 7/7. Установить пакеты ресурсов для шаблонов? (larrock:assets)')) {
80
                $this->call('larrock:assets');
81
            }
82
        }
83
84
        $this->info('=== Install LarrockCMS successfully ended ===');
85
        $this->line('Проверка корректности установки LarrockCMS - php artisan larrock:check');
86
        $this->line('Если вы хотите установить пакеты не входящие в ядро LarrockCMS, выполните команду php artisan larrock:manager');
87
    }
88
}