File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,4 +66,23 @@ static public function info(string $message) {
6666 static public function warning (string $ message ) {
6767 return fwrite (STDERR , "\033[1;33m " . $ message . "\033[0m \n" );
6868 }
69+
70+ /**
71+ * Warning
72+ *
73+ * Log warning messages to console
74+ *
75+ * @param string $message
76+ * @return bool|int
77+ */
78+ static public function confirm (string $ question ) {
79+ self ::log ($ question );
80+
81+ $ handle = fopen ('php://stdin ' , 'r ' );
82+ $ line = trim (fgets ($ handle ));
83+
84+ fclose ($ handle );
85+
86+ return $ line ;
87+ }
6988}
Original file line number Diff line number Diff line change @@ -34,5 +34,6 @@ public function testLogs()
3434 $ this ->assertEquals (15 , Console::error ('error ' ));
3535 $ this ->assertEquals (14 , Console::info ('info ' ));
3636 $ this ->assertEquals (19 , Console::warning ('warning ' ));
37+ $ this ->assertEquals ('this is an answer ' , Console::confirm ('this is a question ' ));
3738 }
3839}
Original file line number Diff line number Diff line change 1+ this is an answer
You can’t perform that action at this time.
0 commit comments