convert() public static method

                 text      text            background
     ------------------------------------------------
     %k %k %0    black     dark grey       black
     %r %r %1    red       bold red        red
     %g %g %2    green     bold green      green
     %y %y %3    yellow    bold yellow     yellow
     %b %b %4    blue      bold blue       blue
     %m %m %5    magenta   bold magenta    magenta
     %p %p       magenta (think: purple)
     %c %c %6    cyan      bold cyan       cyan
     %w %w %7    white     bold white      white

     %f     blinking, flashing
     %u     underline
     %8     reverse
     %_,%9  bold

     %n     resets the color
     %%     a single %
first param is the string to convert, second is an optional flag if colors should be used. it defaults to true, if set to false, the colorcodes will just be removed (and %% will be transformed into %)
public static convert ( string $string, boolean $colored = true ) : string
$string string string to convert
$colored boolean should the string be colored?
return string
Esempio n. 1
0
 /**
  * Writes the message $msg to STDERR.
  *
  * @param string $msg The message to output
  * @param string $status Output status
  *
  * @return \Phrozn\Outputter
  */
 public function stderr($msg, $status = self::STATUS_FAIL)
 {
     if (defined('STDERR')) {
         fwrite(STDERR, $msg);
     } else {
         $msg = Color::strip(Color::convert($msg));
         $this->lines[] = trim($msg);
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Writes the message $msg to STDERR.
  *
  * @param string $msg The message to output
  * @param string $status Output status
  *
  * @return \Phrozn\Outputter
  */
 public function stderr($msg, $status = self::STATUS_FAIL)
 {
     $msg = Color::convert($status . $msg . "\n");
     if (defined('STDERR')) {
         fwrite(STDERR, $msg);
     } else {
         echo $msg;
         if (count(\ob_get_status()) !== 0) {
             ob_flush();
         }
     }
     return $this;
 }
Esempio n. 3
0
 protected function pad($str)
 {
     return str_repeat(' ', strlen(Color::strip(Color::convert($str))));
 }