Phulp\Output::colorize PHP Method

colorize() public static method

This method is used to colorize some text
public static colorize ( string $string, string $color ) : string
$string string the text to be colorized
$color string the color to colorize your
return string
    public static function colorize($string, $color)
    {
        if (isset(self::$colors[$color])) {
            return "[" . self::$colors[$color] . 'm' . $string . "";
        }
        return $string;
    }

Usage Example

Beispiel #1
0
 /**
  * @param Source $src
  * @param mixed $tasks
  *
  * @return Watch
  *
  * @throws \InvalidArgumentException
  */
 public function watch(Source $src, $tasks)
 {
     if (!is_array($tasks) && !is_callable($tasks)) {
         throw new \InvalidArgumentException('Invalid Argument for Phulp::watch');
     }
     if (is_array($tasks)) {
         Output::out('[' . Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray') . '] ' . Output::colorize('the API of Phulp::watch you are using will be deprecated', 'yellow'));
         Output::out('[' . Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray') . '] ' . Output::colorize('Please check the documentation. ', 'yellow'));
     }
     return new Watch($src, $tasks, $this);
 }