IdeHelperRun   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Console\Commands;
12
13
use Illuminate\Console\Command;
14
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
15
16
/**
17
 * Class IdeHelperRun.
18
 *
19
 * Класс запсукает все команды ide-helper пакета.
20
 * Просто для хелпер, чтобы не париться и упростить генерацию.
21
 */
22
class IdeHelperRun extends Command
23
{
24
    /**
25
     * Основное приложение. Оно есть в базовой команде, но там не работает автокомплит.
26
     * по-этому переопределим его тут. Мешать не будет, а автокомплит появится.
27
     *
28
     * @var \Illuminate\Foundation\Application
29
     */
30
    protected $laravel;
31
32
    /**
33
     * Название нашей консольной команды.
34
     *
35
     * @var string
36
     */
37
    protected $signature = 'ide-helper:run';
38
39
    /**
40
     * Краткое описание нашей консольной команды.
41
     *
42
     * @var string
43
     */
44
    protected $description = 'Generate a IDE Helper files if current environment is local.';
45
46
    /**
47
     * Метод выполняет саму команду, которая генерирует хелперы для IDE.
48
     * Помимо этого добавим проверку на окружение. На боевом сервере эти хелперы просто не нужны.
49
     *
50
     * @return void
51
     */
52
    public function handle(): void
53
    {
54
        if (! $this->laravel->getProvider(IdeHelperServiceProvider::class)) {
55
            $env = $this->laravel->environment();
56
            $this->info(sprintf('Skipped. IdeHelper not registered for %s environment.', $env));
57
58
            return;
59
        }
60
61
        $this->call('ide-helper:generate');
62
        $this->call('ide-helper:meta');
63
        $this->call('ide-helper:models', ['--nowrite' => null]);
64
    }
65
}
66