Bluz\Cli\Colorize::text PHP Метод

text() публичный статический Метод

Return string colorized for Linux console
public static text ( string $text, string $foreground = null, string $background = null, boolean $bold = false, boolean $underline = false ) : string
$text string
$foreground string
$background string
$bold boolean
$underline boolean
Результат string
    public static function text($text, $foreground = null, $background = null, $bold = false, $underline = false)
    {
        $colored = "[";
        if ($bold) {
            $colored .= '1;';
        }
        if ($underline) {
            $colored .= '4;';
        }
        if ($foreground !== null && isset(self::$colors[$foreground])) {
            $colored .= self::$colors[$foreground] . ";";
        }
        if ($background !== null && isset(self::$background[$background])) {
            $colored .= self::$background[$background] . ";";
        }
        $colored = rtrim($colored, ';');
        $colored .= "m" . $text . "";
        return $colored;
    }

Usage Example

Пример #1
0
 /**
  * @param \PHPUnit_Framework_TestSuite $suite
  * @return void
  */
 public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $time = sprintf('%0.3f sec', microtime(1) - $this->timeSuite);
     echo "\n";
     echo Colorize::text("Suite Time: " . $time, 'white', null, true);
     echo "\n";
 }
Colorize