Passed
Push — master ( bbbee0...340b31 )
by Caen
03:42 queued 15s
created

DebugCommand::printEnabledFeatures()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
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
        $this->newLine();
40
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
        $this->newLine();
45
46
        $this->comment('App Env: '.(string) app('env'));
47
        $this->newLine();
48
49
        if ($this->output->isVerbose()) {
50
            $this->printVerbosePathInformation();
51
        } else {
52
            $this->comment('Project directory: '.Hyde::path());
53
        }
54
        $this->newLine();
55
56
        $this->line('Enabled features:');
57
        $this->printEnabledFeatures();
58
59
        return Command::SUCCESS;
60
    }
61
62
    protected function printVerbosePathInformation(): void
63
    {
64
        $this->line('Project directory:');
65
        $this->line(' > '.realpath(Hyde::path()));
66
        $this->line('Framework vendor path:');
67
        $this->line(' > '.(str_replace('/', DIRECTORY_SEPARATOR, Hyde::vendorPath()).' (vendor)'));
68
        $this->line(' > '.realpath(Hyde::vendorPath()).' (real)');
69
    }
70
71
    protected function printEnabledFeatures(): void
72
    {
73
        foreach (Config::getArray('hyde.features') as $feature) {
74
            $this->line(" - $feature");
75
        }
76
    }
77
}
78