Skip to content

Commit

Permalink
Minor cleanup on ListModulesCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Jul 1, 2023
1 parent 2fb2224 commit 8f1c695
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 66 deletions.
70 changes: 35 additions & 35 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 27 additions & 26 deletions src/Console/Infrastructure/Command/ListModulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,6 @@ private function generateListOfModules(bool $isDetailed, array $modules): void
}
}

/**
* @param list<AppModule> $modules
*/
private function generateSimpleView(array $modules): void
{
$rows = [];

foreach ($modules as $module) {
$rows[] = [
$module->fullModuleName(),
self::CHECK_SYMBOL, // facade is always true
$module->factoryClass() ? self::CHECK_SYMBOL : self::CROSS_SYMBOL,
$module->configClass() ? self::CHECK_SYMBOL : self::CROSS_SYMBOL,
$module->dependencyProviderClass() ? self::CHECK_SYMBOL : self::CROSS_SYMBOL,
];
}
$table = new Table($this->output());
$table->setStyle('box');
$table->setHeaders(['Module namespace', 'Facade', 'Factory', 'Config', 'Dep. Provider']);
$table->setRows($rows);
$table->render();
}

/**
* @param list<AppModule> $modules
*/
Expand All @@ -97,9 +74,9 @@ private function generateDetailedView(array $modules): void
$result = '';
foreach ($modules as $i => $module) {
$n = $i + 1;
$factory = $module->factoryClass() ?? 'None';
$config = $module->configClass() ?? 'None';
$dependencyProviderClass = $module->dependencyProviderClass() ?? 'None';
$factory = $module->factoryClass() ?? self::CROSS_SYMBOL;
$config = $module->configClass() ?? self::CROSS_SYMBOL;
$dependencyProviderClass = $module->dependencyProviderClass() ?? self::CROSS_SYMBOL;

$result .= <<<TXT
============================
Expand All @@ -115,4 +92,28 @@ private function generateDetailedView(array $modules): void

$this->output()->write($result);
}

/**
* @param list<AppModule> $modules
*/
private function generateSimpleView(array $modules): void
{
$rows = [];

foreach ($modules as $module) {
$rows[] = [
$module->fullModuleName(),
self::CHECK_SYMBOL, // facade is always true
$module->factoryClass() ? self::CHECK_SYMBOL : self::CROSS_SYMBOL,
$module->configClass() ? self::CHECK_SYMBOL : self::CROSS_SYMBOL,
$module->dependencyProviderClass() ? self::CHECK_SYMBOL : self::CROSS_SYMBOL,
];
}

$table = new Table($this->output());
$table->setStyle('box');
$table->setHeaders(['Module namespace', 'Facade', 'Factory', 'Config', 'Dep. Provider']);
$table->setRows($rows);
$table->render();
}
}
10 changes: 5 additions & 5 deletions tests/Feature/Console/ListModules/ListModulesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ public function test_list_modules(): void
Facade: GacelaTest\Feature\Console\ListModules\LevelUp\TestModule3\TestModule3Facade
Factory: GacelaTest\Feature\Console\ListModules\LevelUp\TestModule3\TestModule3Factory
Config: GacelaTest\Feature\Console\ListModules\LevelUp\TestModule3\TestModule3Config
DependencyProvider: None
DependencyProvider: ✖️
============================
2.- TestModule1
----------------------------
Facade: GacelaTest\Feature\Console\ListModules\TestModule1\TestModule1Facade
Factory: GacelaTest\Feature\Console\ListModules\TestModule1\TestModule1Factory
Config: None
Config: ✖️
DependencyProvider: GacelaTest\Feature\Console\ListModules\TestModule1\TestModule1DependencyProvider
============================
3.- TestModule2
----------------------------
Facade: GacelaTest\Feature\Console\ListModules\TestModule2\TestModule2Facade
Factory: None
Config: None
DependencyProvider: None
Factory: ✖️
Config: ✖️
DependencyProvider: ✖️
TXT;
self::assertSame($expected, $this->command->getDisplay());
Expand Down

0 comments on commit 8f1c695

Please sign in to comment.