EnvListCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace msztorc\LaravelEnv\Commands;
4
5
use Illuminate\Console\Command;
6
use msztorc\LaravelEnv\Commands\Traits\CommandValidator;
7
use msztorc\LaravelEnv\Env;
8
9
class EnvListCommand extends Command
10
{
11
    use CommandValidator;
12
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'env:list {key?} {--json}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'List all variables from an environment file';
26
27
    /**
28
     * json format argument
29
     *
30
     * @var bool
31
     */
32
    protected $json;
33
34
    /**
35
     * Env object
36
     *
37
     * @var object
38
     */
39
    protected $env;
40
41
    /**
42
     * Create a new command instance.
43
     *
44
     * @return void
45
     */
46
    public function __construct()
47
    {
48
        parent::__construct();
49
    }
50
51
    /**
52
     * Execute the console command.
53
     *
54
     * @return mixed
55
     */
56
    public function handle()
57
    {
58
        $this->json = (bool)$this->option('json');
59
60
        $this->env = new Env();
61
        $this->line($this->_getEntireEnvContent());
62
    }
63
64
    private function _getEntireEnvContent()
65
    {
66
        return ($this->json) ? json_encode($this->env->getVariables()) : $this->env->getEnvContent();
67
    }
68
}
69