Skip to content

Commit

Permalink
Refactored the input() method to use the internal write() method inst…
Browse files Browse the repository at this point in the history
…ead of calling fwrite seperately.
  • Loading branch information
allebb committed Jan 19, 2016
1 parent abe6c2e commit 92fe2e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ public function writeln($text = '')
public function input($question, $default = '', $options = [])
{
if (empty($default)) {
fwrite(STDOUT, $question . ' ');
$this->write($question . ' ');
} elseif (empty($options)) {
fwrite(STDOUT, $question . ' [' . $default . '] ');
$this->write($question . ' [' . $default . '] ');
} else {
foreach (strtolower($options) as $option) {
if ($option === strtolower($default)) {
Expand All @@ -142,7 +142,7 @@ public function input($question, $default = '', $options = [])
$available_options[] = $option;
}
$available_opts = rtrim(implode($available_options, '/'), '/');
fwrite(STDOUT, $question . ' [' . $available_opts . '] ');
$this->write($question . ' [' . $available_opts . '] ');
}
$answer = rtrim(fgets(STDIN), PHP_EOL);
if (empty($answer)) {
Expand Down

0 comments on commit 92fe2e3

Please sign in to comment.