diff --git a/src/Command/ExecCommand.php b/src/Command/ExecCommand.php index b442751..4ee293d 100644 --- a/src/Command/ExecCommand.php +++ b/src/Command/ExecCommand.php @@ -144,17 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - // Determine number of workers. - $workers = $input->getOption('drall-workers'); - - if ($workers > self::WORKER_LIMIT) { - $this->logger->warning('Limiting workers to {count}, which is the maximum.', ['count' => self::WORKER_LIMIT]); - $workers = self::WORKER_LIMIT; - } - - if ($workers > 1) { - $this->logger->notice("Using {count} workers.", ['count' => $workers]); - } + $workers = $this->getWorkerCount($input); // Display commands without executing them. if ($input->getOption('drall-no-execute')) { @@ -227,6 +217,30 @@ protected function getCommand(): RawCommand { return $command; } + /** + * Gets the number of workers that should be used. + * + * @param \Symfony\Component\Console\Input\InputInterface $input + * The input. + * + * @return int + * Number of workers to be used. + */ + protected function getWorkerCount(InputInterface $input): int { + $result = $input->getOption('drall-workers'); + + if ($result > self::WORKER_LIMIT) { + $this->logger->warning('Limiting workers to {count}, which is the maximum.', ['count' => self::WORKER_LIMIT]); + $result = self::WORKER_LIMIT; + } + + if ($result > 1) { + $this->logger->notice("Using {count} workers.", ['count' => $result]); + } + + return $result; + } + /** * Get unique placeholder from a command. */ diff --git a/test/Unit/Command/ExecCommandTest.php b/test/Unit/Command/ExecCommandTest.php index 0c56b65..742840e 100644 --- a/test/Unit/Command/ExecCommandTest.php +++ b/test/Unit/Command/ExecCommandTest.php @@ -98,7 +98,7 @@ public function testWithMixedPlaceholders() { } /** - * Drall caps the maximum number of workers. + * Drall caps the maximum number of workers to pre-determined limit. */ public function testWorkerLimit() { $input = [