EnvListCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 58
rs 10
c 2
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A _getEntireEnvContent() 0 3 2
A handle() 0 6 1
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