From afdcee84aeffa8d6bf3dd0add47011b7fc67f300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 1 Sep 2021 07:45:52 +0200 Subject: [PATCH] UtilsRandomCommand: count move to own property --- src/Command/Utils/UtilsRandomCommand.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Command/Utils/UtilsRandomCommand.php b/src/Command/Utils/UtilsRandomCommand.php index 5d85223..4b6674f 100644 --- a/src/Command/Utils/UtilsRandomCommand.php +++ b/src/Command/Utils/UtilsRandomCommand.php @@ -32,16 +32,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int $table = new Table($output); $table->setHeaders(['ID', 'Generated strings']); - for ($i = 1; $i <= $input->getOption('count'); $i++) { + $count = min((int) $input->getOption('count'), 1); + for ($i = 1; $i <= $count; $i++) { $table->addRow([$i, Random::generate(50)]); - if ($i !== intval($input->getOption('count'))) { + if ($i !== $count) { $table->addRow(new TableSeparator()); } } $table->render(); - $style->success(sprintf('Total generated strings %d.', intval($input->getOption('count')))); + $style->success(sprintf('Total generated strings %d.', $count)); return 0; }