Passed
Push — master ( a34831...34d521 )
by Miroslaw
04:02
created

EnvListCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 62
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A _printAllEnvValues() 0 4 2
A handle() 0 7 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
        return $this->_printAllEnvValues();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_printAllEnvValues() targeting msztorc\LaravelEnv\Comma...d::_printAllEnvValues() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
65
66
    }
67
68
    private function _printAllEnvValues()
69
    {
70
        $this->line(($this->json) ? json_encode($this->env->getVariables()) : $this->env->getEnvContent());
71
        return;
72
    }
73
}
74