diff --git a/src/Lib/Message.php b/src/Lib/Message.php index 4ead518..4b4148e 100644 --- a/src/Lib/Message.php +++ b/src/Lib/Message.php @@ -42,7 +42,8 @@ class Message 'light gray' => '47', ]; - public function __get($name){ + public function __get($name) + { return $this->$name; } @@ -54,14 +55,15 @@ public function __construct($message = null) $this->dateFormat("H:i:s > "); } - public function message($message){ + public function message($message) + { $this->message = $message; return $this; } public function foreground($colour) { - if(!array_key_exists($colour, self::$foregroundColours)) { + if (!array_key_exists($colour, self::$foregroundColours)) { throw new \Exception('No such foreground colour `'.$colour.'`'); } $this->foreground = $colour; @@ -70,7 +72,7 @@ public function foreground($colour) public function background($colour) { - if(!array_key_exists($colour, self::$backgroundColours)) { + if (!array_key_exists($colour, self::$backgroundColours)) { throw new \Exception('No such background colour `'.$colour.'`'); } $this->background = $colour; @@ -118,4 +120,4 @@ public function display($target=STDOUT) ) ); } -} \ No newline at end of file +} diff --git a/src/Lib/Utils.php b/src/Lib/Utils.php index 60ac1d4..9875332 100644 --- a/src/Lib/Utils.php +++ b/src/Lib/Utils.php @@ -24,7 +24,7 @@ public static function promptForInput($prompt, $silent = false, $default = null, throw new \Exception("bash cannot be invoked from PHP. 'silent' flag cannot be used."); } - if(!($prompt instanceof Message)) { + if (!($prompt instanceof Message)) { $prompt = new Message($prompt); } @@ -32,24 +32,22 @@ public static function promptForInput($prompt, $silent = false, $default = null, "%s%s: ", $prompt->message, (!is_null($default) ? " [{$default}]" : null) )); - do{ + do { $prompt->display(); - if($silent) { + if ($silent) { $command = "/usr/bin/env bash -c 'read -s in && echo \$in'"; $input = shell_exec($command); echo PHP_EOL; - } else { $input = fgets(STDIN, 256); } $input = trim($input); - if(strlen(trim($input)) == 0 && !is_null($default)){ + if (strlen(trim($input)) == 0 && !is_null($default)) { $input = $default; } - - }while($validator instanceof \Closure && !$validator($input)); + } while ($validator instanceof \Closure && !$validator($input)); return $input; }