promptText = (string) $promptText; $this->echo = (bool) $echo; } /** * Show the prompt to user and return a string. * * @return string */ public function show() { $console = $this->getConsole(); $console->writeLine($this->promptText); $password = ''; /** * Read characters from console */ while (true) { $char = $console->readChar(); $console->clearLine(); if (PHP_EOL == $char) { break; } $password .= $char; if ($this->echo) { $console->write(str_repeat('*', strlen($password))); } } return $password; } }