Skip to content

Commit

Permalink
Missing Php cs
Browse files Browse the repository at this point in the history
  • Loading branch information
olarno committed Nov 4, 2023
1 parent b7df20c commit b7272d8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
69 changes: 35 additions & 34 deletions app/src/Command/ExportListCommandsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,43 @@

class ExportListCommandsCommand extends Command
{
protected static $defaultName = 'app:list-commands';

protected function configure()
{
$this
->setDescription('List all available Symfony commands with their documentation.')
->setHelp('This command lists all available Symfony commands and their descriptions.');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$commands = $this->getApplication()->all();
$commandList = [];

foreach ($commands as $name => $command) {
$description = $this->sanitizeText($command->getDescription());
$synopsis = $this->sanitizeText($command->getSynopsis());
$helper = $this->sanitizeText($command->getHelp());

$commandList[$name]['description'] = $description;
$commandList[$name]['synopsis'] = $synopsis;
$commandList[$name]['helper'] = $helper;
protected static $defaultName = 'app:list-commands';

protected function configure(): void
{
$this
->setDescription('List all available Symfony commands with their documentation.')
->setHelp('This command lists all available Symfony commands and their descriptions.');
}

$jsonOutput = json_encode($commandList, JSON_PRETTY_PRINT);
$output->writeln($jsonOutput);
return 0;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$commands = $this->getApplication()->all();
$commandList = [];

foreach ($commands as $name => $command) {
$description = $this->sanitizeText($command->getDescription());
$synopsis = $this->sanitizeText($command->getSynopsis());
$helper = $this->sanitizeText($command->getHelp());

private function sanitizeText($text)
{
$output = strip_tags($text);
$output = preg_replace('/\s+/', ' ', $output);
$output = str_replace('"', "'", $output);
$output = trim($output);
$commandList[$name]['description'] = $description;
$commandList[$name]['synopsis'] = $synopsis;
$commandList[$name]['helper'] = $helper;
}

return $output;
}
$jsonOutput = json_encode($commandList, \JSON_PRETTY_PRINT);
$output->writeln($jsonOutput);

return 0;
}

private function sanitizeText($text)
{
$output = strip_tags($text);
$output = preg_replace('/\s+/', ' ', $output);
$output = str_replace('"', "'", $output);
$output = trim($output);

return $output;
}
}
13 changes: 7 additions & 6 deletions tests/Command/ExportListCommandsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace App\Tests\Command;

use App\Tests\TestCase;
use App\Command\ExportListCommandsCommand;
use App\Tests\TestCase;
use Draw\Component\Tester\Application\CommandDataTester;
use Draw\Component\Tester\Application\CommandTestTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Draw\Component\Tester\Application\CommandTestTrait;
use Draw\Component\Tester\Application\CommandDataTester;

/**
* @covers \App\Command\ExportListCommandsCommand
Expand Down Expand Up @@ -63,7 +63,8 @@ public function testExecute(): void

private function getDefaultExpectation(): string
{
$jsonContent = file_get_contents(__DIR__.'/result/defaultExport.json');
return $jsonContent;
$jsonContent = file_get_contents(__DIR__.'/result/defaultExport.json');

return $jsonContent;
}
}
}

0 comments on commit b7272d8

Please sign in to comment.