Skip to content

Instantly share code, notes, and snippets.

@mircobabini
Last active December 16, 2015 01:59
Show Gist options
  • Save mircobabini/5359068 to your computer and use it in GitHub Desktop.
Save mircobabini/5359068 to your computer and use it in GitHub Desktop.
PHP Simple interactions with Shell
<?
/**
* @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