Passed
Push — master ( 34d521...7e9112 )
by Miroslaw
03:48
created

EnvListCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

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