Passed
Push — master ( a8119a...bd111d )
by Caen
03:52 queued 15s
created

DebugCommand   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 28
dl 0
loc 54
rs 10
c 2
b 0
f 0
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A enabledFeatures() 0 3 1
A handle() 0 31 5
A __construct() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Console\Commands;
6
7
use Composer\InstalledVersions;
8
use Hyde\Facades\Config;
9
use Hyde\Hyde;
10
use LaravelZero\Framework\Commands\Command;
11
12
/**
13
 * Hyde Command to print debug information.
14
 */
15
class DebugCommand extends Command
16
{
17
    /** @var string */
18
    protected $signature = 'debug';
19
20
    /** @var string */
21
    protected $description = 'Print debug info';
22
23
    public function __construct()
24
    {
25
        parent::__construct();
26
27
        if (config('app.env', 'production') !== 'development') {
28
            $this->setHidden();
29
        }
30
    }
31
32
    public function handle(): int
33
    {
34
        $this->info('HydePHP Debug Screen');
35
36
        $this->newLine();
37
        $this->comment('Git Version: '.app('git.version'));
0 ignored issues
show
Bug introduced by
Are you sure app('git.version') of type Illuminate\Contracts\Foundation\Application|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        $this->comment('Git Version: './** @scrutinizer ignore-type */ app('git.version'));
Loading history...
38
        $this->comment('Hyde Version: '.(InstalledVersions::getPrettyVersion('hyde/hyde') ?: 'unreleased'));
39
        $this->comment('Framework Version: '.(InstalledVersions::getPrettyVersion('hyde/framework') ?: 'unreleased'));
40
41
        $this->newLine();
42
        $this->comment('App Env: '.app('env'));
0 ignored issues
show
Bug introduced by
Are you sure app('env') of type Illuminate\Contracts\Foundation\Application|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
        $this->comment('App Env: './** @scrutinizer ignore-type */ app('env'));
Loading history...
43
44
        $this->newLine();
45
        if ($this->getOutput()->isVerbose()) {
46
            $this->line('Project directory:');
47
            $this->line(' > '.realpath(Hyde::path()));
48
            $this->line('Framework vendor path:');
49
            $this->line(' > '.(str_replace('/', DIRECTORY_SEPARATOR, Hyde::vendorPath()).' (vendor)'));
50
            $this->line(' > '.realpath(Hyde::vendorPath()).' (real)');
51
        } else {
52
            $this->comment('Project directory: '.Hyde::path());
53
        }
54
55
        $this->newLine();
56
57
        $this->line('Enabled features:');
58
        foreach ($this->enabledFeatures() as $feature) {
59
            $this->line(" - $feature");
60
        }
61
62
        return Command::SUCCESS;
63
    }
64
65
    /** @return array<string> */
66
    protected function enabledFeatures(): array
67
    {
68
        return Config::getArray('hyde.features');
69
    }
70
}
71