Skip to content

Commit

Permalink
chore: replace method wrappers with extend
Browse files Browse the repository at this point in the history
  • Loading branch information
imdhemy committed Mar 27, 2024
1 parent dd41633 commit dacc299
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 123 deletions.
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure(): void
public function run(InputInterface $input, OutputInterface $output): int
{
$this->setInput($input);
$this->setOutput(new Output(StyleFactory::create($input, $output)));
$this->setOutput(new Output($input, StyleFactory::create($input, $output)));

return parent::run($input, $output);
}
Expand Down
2 changes: 1 addition & 1 deletion src/IO/Helper/OutputTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function line(string $message, ?string $style = null): void
{
$styled = $style ? "<$style>$message</$style>" : $message;

$this->output->line($styled);
$this->output->writeln($styled);
}

protected function note(string|array $message): void
Expand Down
122 changes: 1 addition & 121 deletions src/IO/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,133 +4,13 @@

namespace Symblaze\Console\IO;

use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
* The Symblaze output helper class.
*
* @internal - This class is for internal use only
*/
class Output
class Output extends SymfonyStyle
{
public function __construct(private readonly SymfonyStyle $style)
{
}

public function line(string $message): void
{
$this->style->writeln($message);
}

public function info(string $message): void
{
$this->style->info($message);
}

public function comment(string $message): void
{
$this->style->comment($message);
}

public function error(string $message): void
{
$this->style->error($message);
}

public function warning(string $message): void
{
$this->style->warning($message);
}

public function success(string $message): void
{
$this->style->success($message);
}

public function title(string $message): void
{
$this->style->title($message);
}

public function section(string $message): void
{
$this->style->section($message);
}

public function text(string $message): void
{
$this->style->text($message);
}

public function listing(array $elements): void
{
$this->style->listing($elements);
}

public function table(array $headers, array $rows): void
{
$this->style->table($headers, $rows);
}

public function horizontalTable(array $headers, array $rows): void
{
$this->style->horizontalTable($headers, $rows);
}

public function definitionList(string|array|TableSeparator ...$list): void
{
$this->style->definitionList(...$list);
}

public function note(string $message): void
{
$this->style->note($message);
}

public function caution(string $message): void
{
$this->style->caution($message);
}

public function ask(string $question, ?string $default = null, ?callable $validator = null): mixed
{
return $this->style->ask($question, $default, $validator);
}

public function askHidden(string $question, ?callable $validator = null): mixed
{
return $this->style->askHidden($question, $validator);
}

public function confirm(string $question, bool $default = true): bool
{
return $this->style->confirm($question, $default);
}

public function choice(string $question, array $choices, mixed $default = null, bool $multiSelect = false): mixed
{
return $this->style->choice($question, $choices, $default, $multiSelect);
}

public function progressStart(int $max = 0): void
{
$this->style->progressStart($max);
}

public function progressAdvance(int $step = 1): void
{
$this->style->progressAdvance($step);
}

public function progressFinish(): void
{
$this->style->progressFinish();
}

public function createProgressBar(int $max = 0): ProgressBar
{
return $this->style->createProgressBar($max);
}
}

0 comments on commit dacc299

Please sign in to comment.