LarrockUpdateEnvCommand   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 32
c 2
b 1
f 1
dl 0
loc 72
rs 10
wmc 10

1 Method

Rating   Name   Duplication   Size   Complexity  
D handle() 0 50 10
1
<?php
2
3
namespace Larrock\Core\Commands;
4
5
use Illuminate\Console\Command;
6
7
class LarrockUpdateEnvCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'larrock:updateEnv';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Update Laravel .env to Larrock';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return mixed
27
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
28
     */
29
    public function handle()
30
    {
31
        $this->line('=== Check Laravel .env ===');
32
33
        if (! env('LARROCK VARS')) {
34
            $this->info('=== Add LARROCK vars ===');
35
            \File::append(base_path('.env'), "\n\nLARROCK VARS=PLACED");
36
        }
37
38
        if (! env('MAIL_TEMPLATE_ADDRESS')) {
39
            \File::append(base_path('.env'), "\nMAIL_TEMPLATE_ADDRESS='company address'");
40
            $this->info('MAIL_FROM_ADDRESS not found. Add "company address"');
41
        }
42
43
        if (! env('MAIL_TEMPLATE_PHONE')) {
44
            \File::append(base_path('.env'), "\nMAIL_TEMPLATE_PHONE='company phone'");
45
            $this->info('MAIL_TEMPLATE_PHONE not found. Add "company phone"');
46
        }
47
48
        if (! env('MAIL_TEMPLATE_MAIL')) {
49
            \File::append(base_path('.env'), "\[email protected]");
50
            $this->info('MAIL_TEMPLATE_MAIL not found. Add "[email protected]"');
51
        }
52
53
        if (! env('MAIL_FROM_ADDRESS')) {
54
            \File::append(base_path('.env'), "\[email protected]");
55
            $this->info('MAIL_FROM_ADDRESS not found. Add "[email protected]"');
56
        }
57
58
        if (! env('MAIL_TO_ADMIN')) {
59
            \File::append(base_path('.env'), "\[email protected]");
60
            $this->info('MAIL_TO_ADMIN not found. Add "[email protected]"');
61
        }
62
63
        if (! env('MAIL_FROM_NAME')) {
64
            \File::append(base_path('.env'), "\nMAIL_FROM_NAME='LARROCK'");
65
            $this->info('MAIL_FROM_NAME not found. Add "LARROCK"');
66
        }
67
68
        if (! env('SITE_NAME')) {
69
            \File::append(base_path('.env'), "\nSITE_NAME='LARROCK'");
70
            $this->info('SITE_NAME not found. Add "LARROCK"');
71
        }
72
73
        if (env('MAIL_STOP', false) !== false) {
74
            \File::append(base_path('.env'), "\nMAIL_STOP=false");
75
            $this->info('MAIL_STOP not found. Add "false"');
76
        }
77
78
        $this->info('.env vars currently installed');
79
    }
80
}
81