Completed
Push — master ( c5cc72...7c6f56 )
by Jean-Christophe
02:02
created

Console   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0
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