Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
27 / 27 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
DebugCommand | |
100.00% |
27 / 27 |
|
100.00% |
4 / 4 |
11 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
handle | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
6 | |||
printVerbosePathInformation | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
printEnabledFeatures | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
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 Hyde\Foundation\PharSupport; |
11 | use LaravelZero\Framework\Commands\Command; |
12 | |
13 | use function str_replace; |
14 | use function realpath; |
15 | use function app; |
16 | use function get_included_files; |
17 | |
18 | /** |
19 | * Print debug information. |
20 | */ |
21 | class DebugCommand extends Command |
22 | { |
23 | /** @var string */ |
24 | protected $signature = 'debug'; |
25 | |
26 | /** @var string */ |
27 | protected $description = 'Print debug information'; |
28 | |
29 | public function __construct() |
30 | { |
31 | parent::__construct(); |
32 | |
33 | if (Config::getString('app.env', 'production') !== 'development') { |
34 | $this->setHidden(); |
35 | } |
36 | } |
37 | |
38 | public function handle(): int |
39 | { |
40 | $this->info('HydePHP Debug Screen'); |
41 | $this->newLine(); |
42 | |
43 | $this->comment('Hyde Version: '.((InstalledVersions::isInstalled('hyde/hyde') ? InstalledVersions::getPrettyVersion('hyde/hyde') : null) ?: 'unreleased')); |
44 | $this->comment('Framework Version: '.(InstalledVersions::getPrettyVersion('hyde/framework') ?: 'unreleased')); |
45 | $this->newLine(); |
46 | |
47 | $this->comment('App Env: '.(string) app('env')); |
48 | $this->newLine(); |
49 | |
50 | if ($this->output->isVerbose()) { |
51 | $this->printVerbosePathInformation(); |
52 | } else { |
53 | $this->comment('Project directory: '.Hyde::path()); |
54 | |
55 | if (PharSupport::running()) { |
56 | $this->comment('Application binary path: '.get_included_files()[0]); |
57 | } |
58 | } |
59 | $this->newLine(); |
60 | |
61 | $this->line('Enabled features:'); |
62 | $this->printEnabledFeatures(); |
63 | |
64 | return Command::SUCCESS; |
65 | } |
66 | |
67 | protected function printVerbosePathInformation(): void |
68 | { |
69 | $this->line('Project directory:'); |
70 | $this->line(' > '.realpath(Hyde::path())); |
71 | $this->line('Framework vendor path:'); |
72 | $this->line(' > '.(str_replace('/', DIRECTORY_SEPARATOR, Hyde::vendorPath()).' (vendor)')); |
73 | $this->line(' > '.realpath(Hyde::vendorPath()).' (real)'); |
74 | } |
75 | |
76 | protected function printEnabledFeatures(): void |
77 | { |
78 | /** @var array<\Hyde\Enums\Feature> $features */ |
79 | $features = Config::getArray('hyde.features', []); |
80 | |
81 | foreach ($features as $feature) { |
82 | $this->line(" - $feature->name"); |
83 | } |
84 | } |
85 | } |