From b4364aa0143903498d938dc58508b0e44be74c01 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 8 May 2019 22:08:18 +0200 Subject: [PATCH] refactored code --- .../Component/Console/Helper/QuestionHelper.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index 757fed4746de..2d910f435611 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -367,19 +367,17 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu private function mostRecentlyEnteredValue($entered) { - $tempEntered = $entered; - // Determine the most recent value that the user entered - if (false !== strpos($entered, ',')) { - $choices = explode(',', $entered); - $lastChoice = trim($choices[\count($choices) - 1]); + if (false === strpos($entered, ',')) { + return $entered; + } - if (\strlen($lastChoice) > 0) { - $tempEntered = $lastChoice; - } + $choices = explode(',', $entered); + if (\strlen($lastChoice = trim($choices[\count($choices) - 1])) > 0) { + return $lastChoice; } - return $tempEntered; + return $entered; } /**