Passed
Push — master ( 2aed56...dab7ab )
by Caen
04:13 queued 13s
created

DebugCommand   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 54
rs 10
wmc 9

3 Methods

Rating   Name   Duplication   Size   Complexity  
A enabledFeatures() 0 3 1
A __construct() 0 6 2
B handle() 0 31 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Console\Commands;
6
7
use Hyde\Hyde;
8
use Hyde\Facades\Config;
9
use Composer\InstalledVersions;
10
use LaravelZero\Framework\Commands\Command;
11
12
use function str_replace;
13
use function realpath;
14
use function app;
15
16
/**
17
 * Hyde Command to print debug information.
18
 */
19
class DebugCommand extends Command
20
{
21
    /** @var string */
22
    protected $signature = 'debug';
23
24
    /** @var string */
25
    protected $description = 'Print debug info';
26
27
    public function __construct()
28
    {
29
        parent::__construct();
30
31
        if (Config::getString('app.env', 'production') !== 'development') {
32
            $this->setHidden();
33
        }
34
    }
35
36
    public function handle(): int
37
    {
38
        $this->info('HydePHP Debug Screen');
39
40
        $this->newLine();
41
        $this->comment('Git Version: '.(string) app('git.version'));
42
        $this->comment('Hyde Version: '.((InstalledVersions::isInstalled('hyde/hyde') ? InstalledVersions::getPrettyVersion('hyde/hyde') : null) ?: 'unreleased'));
43
        $this->comment('Framework Version: '.(InstalledVersions::getPrettyVersion('hyde/framework') ?: 'unreleased'));
44
45
        $this->newLine();
46
        $this->comment('App Env: '.(string) app('env'));
47
48
        $this->newLine();
49
        if ($this->getOutput()->isVerbose()) {
50
            $this->line('Project directory:');
51
            $this->line(' > '.realpath(Hyde::path()));
52
            $this->line('Framework vendor path:');
53
            $this->line(' > '.(str_replace('/', DIRECTORY_SEPARATOR, Hyde::vendorPath()).' (vendor)'));
54
            $this->line(' > '.realpath(Hyde::vendorPath()).' (real)');
55
        } else {
56
            $this->comment('Project directory: '.Hyde::path());
57
        }
58
59
        $this->newLine();
60
61
        $this->line('Enabled features:');
62
        foreach ($this->enabledFeatures() as $feature) {
63
            $this->line(" - $feature");
64
        }
65
66
        return Command::SUCCESS;
67
    }
68
69
    /** @return array<string> */
70
    protected function enabledFeatures(): array
71
    {
72
        return Config::getArray('hyde.features');
73
    }
74
}
75