Last active
December 16, 2015 01:59
-
-
Save mircobabini/5359068 to your computer and use it in GitHub Desktop.
PHP Simple interactions with Shell
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
<? | |
/** | |
* @author _LameMind <[email protected]> | |
*/ | |
abstract class LinuxSystem { | |
/** | |
* @param string $question | |
* @param array $admittedValues | |
* @return mixed | |
*/ | |
public static function askTerminal ($question, $admittedValues = array ("Y" => true, "N" => false)) { | |
$questionStr = $question . " [" . implode (",", array_keys ($admittedValues)) . "]"; | |
do { | |
$answer = readline ($questionStr); | |
} | |
while (!isset ($admittedValues[ $answer ])); | |
return $admittedValues[ $answer ]; | |
} | |
/** | |
* @param string $message | |
*/ | |
public static function notifyTerminal ($message) { | |
readline ($message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment