-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from genesisweb/analysis-AD35Ay
Apply fixes from StyleCI
- Loading branch information
Showing
68 changed files
with
1,297 additions
and
1,042 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
<?php | ||
|
||
|
||
namespace Valet; | ||
|
||
|
||
class CliPrompt | ||
{ | ||
|
||
/** | ||
* Prompts the user for input and shows what they type | ||
* Prompts the user for input and shows what they type. | ||
* | ||
* @param $question | ||
* @param bool $hidden | ||
* @param null $suggestion | ||
* @param null $default | ||
* | ||
* @return string | ||
*/ | ||
public function prompt($question,$hidden = false,$suggestion = null,$default = null) | ||
public function prompt($question, $hidden = false, $suggestion = null, $default = null) | ||
{ | ||
$question = $suggestion? "$question [$suggestion]":$question; | ||
$question = $default? "$question ($default)":$question; | ||
$question = $suggestion ? "$question [$suggestion]" : $question; | ||
$question = $default ? "$question ($default)" : $question; | ||
$question .= PHP_EOL; | ||
|
||
print_r($question); | ||
|
||
if($hidden) system('stty -echo'); | ||
if ($hidden) { | ||
system('stty -echo'); | ||
} | ||
$answer = self::trimAnswer(fgets(STDIN, 4096)); | ||
if($hidden) system('stty echo'); | ||
if ($hidden) { | ||
system('stty echo'); | ||
} | ||
|
||
return !empty($answer)?$answer:$default; | ||
return !empty($answer) ? $answer : $default; | ||
} | ||
|
||
private static function trimAnswer($str) | ||
{ | ||
return preg_replace('{\r?\n$}D', '', $str); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.