/** * Response * Imprime un mensaje con formato CLI * * @param array/string $msg Texto de mensaje * @param int $type Tipo de mensaje * 1 = Normal * 2 = Advertencia * * @return true * ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ * @author Luis Gdonis <*****@*****.**> * @since 3.0.0 alpha */ public static function response($msg, $type = 1) { /* * Si es un vector de texto */ if (is_array($msg)) { /* * Imprime el mensaje de forma recursiva */ foreach ($msg as $index => $value) { SELF::response($index . ' : ' . $value); } return; } /* * Da formato a la parte final del mensaje * segun el tipo de mensaje */ switch ($type) { case 1: // Normal $msg_end = ''; break; case 2: // Advertencia $msg_end = chr(33); break; case 3: // Error $msg_end = chr(33) . chr(33) . chr(33); break; case 4: // Final $msg_end = PHP_EOL . PHP_EOL; $msg_end .= '---------------------------------'; $msg_end .= PHP_EOL; $msg_end .= ' Lesli CLI - PHP Web Framework'; $msg_end .= PHP_EOL; $msg_end .= '---------------------------------'; break; case 5: // Separador $msg = '- - - - - - - - - - -'; default: $msg_end = ''; } /* * Imprime un mensaje simple */ fwrite(STDOUT, $msg . $msg_end . PHP_EOL); }