1 | <?php |
||
2 | class Console { |
||
3 | public static function readline(){ |
||
4 | return rtrim(fgets(STDIN)); |
||
5 | } |
||
6 | |||
7 | public static function question($prompt,array $propositions=null){ |
||
8 | echo $prompt; |
||
9 | if(is_array($propositions)){ |
||
10 | echo " (".implode("/", $propositions).")\n"; |
||
11 | do{ |
||
12 | $answer=self::readline(); |
||
13 | }while(array_search($answer, $propositions)===false); |
||
14 | }else |
||
15 | $answer=self::readline(); |
||
16 | |||
17 | return $answer; |
||
18 | } |
||
19 | |||
20 | public static function isYes($answer){ |
||
21 | return array_search($answer, ["yes","y"])!==false; |
||
22 | } |
||
23 | } |
||
24 |