| Total Complexity | 12 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class BasicMsg |
||
| 8 | { |
||
| 9 | public static function displayMsg( |
||
| 10 | string $msg, |
||
| 11 | string $txtColor = 'white', |
||
| 12 | string $txtStyle = 'normal' |
||
| 13 | ) { |
||
| 14 | 1 | $nbArgs = func_num_args(); |
|
| 15 | |||
| 16 | 1 | if ($nbArgs === 1) { |
|
| 17 | 1 | echo $msg; |
|
| 18 | 1 | static::flush(); |
|
| 19 | |||
| 20 | 1 | return; |
|
| 21 | } |
||
| 22 | |||
| 23 | 1 | $txtStyleCode = static::obtainTxtStyleCode($txtStyle); |
|
| 24 | 1 | $txtColorCode = static::obtainTxtColorCode($txtColor); |
|
| 25 | |||
| 26 | 1 | echo "\033[".$txtStyleCode.";".$txtColorCode."m".$msg."\033[0m"; |
|
| 27 | 1 | static::flush(); |
|
| 28 | 1 | } |
|
| 29 | |||
| 30 | public static function displayMsgNL( |
||
| 31 | string $msg, |
||
| 32 | string $txtColor = 'white', |
||
| 33 | string $txtStyle = 'normal' |
||
| 34 | ) { |
||
| 35 | 1 | $nbArgs = func_num_args(); |
|
| 36 | 1 | if ($nbArgs === 1) { |
|
| 37 | 1 | static::displayMsg($msg); |
|
| 38 | 1 | echo "\n"; |
|
| 39 | 1 | static::flush(); |
|
| 40 | 1 | return; |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | static::displayMsg($msg, $txtColor, $txtStyle); |
|
| 44 | 1 | echo "\n"; |
|
| 45 | 1 | static::flush(); |
|
| 46 | 1 | } |
|
| 47 | |||
| 48 | protected static function flush() |
||
| 52 | } |
||
| 53 | 1 | } |
|
| 54 | |||
| 55 | protected static function obtainTxtColorCode(string $txtColor): int |
||
| 66 | } |
||
| 67 | |||
| 68 | protected static function obtainTxtStyleCode(string $txtStyle): int |
||
| 75 | } |
||
| 76 | } |
||
| 77 |