Style/colour a string.
Can be any of: black, red, green, yellow, blue, magenta, cyan, white, bold, italic, underline.

@param string $string
@param array|string $colourOrStyle A single style as a string or multiple styles as an array.

@return string
963257
public function style($string, $colourOrStyle)
    {
        if (is_array($colourOrStyle)) {
            $this->color->__invoke($string);

            while ($style = array_shift($colourOrStyle)) {
                $this->color->apply($style);
            }
            return $this->color->__toString();
        }

        return $this->color->__invoke($string)->apply($colourOrStyle, $string);
    }
687368
public static function html($string) {

        if(null === $string) {
            return '';
        }

		if(true === is_numeric($string)) {
    		return $string;
    	}

		if(false === is_string($string)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($string)), E_USER_ERROR);
		}

        return htmlspecialchars($string, static :: $flags, static :: getEncoding());
    }
69289
public static function color($text, $color)
    {
        if (isset(ShellTool::$colors[$color])) {
            return ShellTool::$colors[$color]['start'] . $text . ShellTool::$colors[$color]['close'];
        } else {
            return $text;
        }
    }
124180
public static function parseStyles($string)
    {
        $styles = array();
        if (empty($string)) {
            return $styles;
        }

        $declarations = preg_split('/\s*;\s*/', $string);

        foreach ($declarations as $declaration) {
            $declaration = trim($declaration);
            if ($declaration === '') {
                continue;
            }
            $split             = preg_split('/\s*:\s*/', $declaration);
            $styles[$split[0]] = $split[1];
        }

        return $styles;
    }
550971
protected function color($string, $type)
    {
        return $this->colourAdapter->colour(
            $string,
            $this->config->getColorForType($type)
        );
    }
1333001
public static function html2rgb( $string )
	{
		sscanf( $string, "%2X%2X%2X", $r, $g, $b );
		return array( $r, $g, $b );
	}
532457
public static function begin($string = '', $color = null, $bold = false)
    {
        return new Line($string, $color, $bold);
    }
329227
public static function formatWithColor(string $color, string $buffer) : string
    {
        $codes   = array_map('trim', explode(',', $color));
        $lines   = explode("\n", $buffer);
        $padding = max(array_map('strlen', $lines));

        $styles = [];
        foreach ($codes as $code) {
            $styles[] = self::$ansiCodes[$code];
        }
        $style = sprintf("\x1b[%sm", implode(';', $styles));

        $styledLines = [];
        foreach ($lines as $line) {
            $styledLines[] = strlen($line) ? $style . str_pad($line, $padding) . "\x1b[0m" : '';
        }

        return implode(PHP_EOL, $styledLines);
    }
1159029
public static function parse($string, array $styles)
    {
        // style the entire string if no tags are found
        if (false === strpos($string, '{')) {
            return self::style($string, reset($styles));
        }

        $i = 0;

        // loop through each tag in the string
        while (false !== $openTag = strpos($string, '{')) {
            $style = array_key_exists($i, $styles) ? $styles[$i] : end($styles);

            $escapeSequence = ($style instanceof Style) ? $style->getEscapeSequence() : self::getEscapeSequence($style);
            $resetSequence = ($style instanceof Style) ? Style::getResetSequence() : self::getResetSequence($style);

            // replace opening tag
            $string = substr_replace($string, $escapeSequence, $openTag, 1);

            if (false === $closeTag = strpos($string, '}')) {
                $closeTag = strlen($string);
            }

            // don't produce multiple identical reset tags next to each other
            if (substr($string, $closeTag - strlen($resetSequence), strlen($resetSequence)) !== $resetSequence) {
                $string = substr_replace($string, $resetSequence, $closeTag, 1);
            }

            $i++;
        }

        return $string;
    }
1257077
public function Format($String) {
      $Result = $String;
      foreach ($this->_Formatters as $FArray) {
         $Result = $FArray[0]->Format($Result);
      }
      return $Result;
   }
712179
public function paint($string)
    {
        $coloredString = "";

        // set foreground color
        if (array_key_exists($this->foreground, $this->foregroundColors)) {
            $coloredString .= "\033[" . $this->foregroundColors[ $this->foreground ] . "m";
        }

        // set background color
        if (array_key_exists($this->background, $this->backgroundColors)) {
            $coloredString .= "\033[" . $this->backgroundColors[ $this->background ] . "m";
        }

        // combine with string and end the painting
        $coloredString .= $string . "\033[0m";

        return $coloredString;
    }
99516
def strip_color!(string)
      [@@mirc_color, @@rgb_color, @@ecma48_color].each do |pattern|
        string.gsub!(pattern, '')
      end
      # strip cancellation codes too if there are no formatting codes
      string.gsub!(@@normal) if !has_color?(string)
      return string
    end
695263
private static String colorString(Color color) {
		return color.getRed() + "," + color.getGreen() + "," + color.getBlue()
				+ "," + color.getAlpha();
	}
558231
public function getColoredString(
        string $string,
        string $foreground_color = null,
        string $background_color = null,
        bool $header = true
    ):string {
        if ($header) {
            $title = "Console Manager - ".CoreManager::getCurrentModule();
            $titleSeparator = $this->copyContent("-", strlen($title) + 10);
            $string = "\n\n" . $title . "\n" . $titleSeparator . "\n\n" . $string . "\n";
        } else {
            $string = "\n\n" . $string . "\n";
        }
        $string = $this->resizeContent($string);
        $colored_string = "";


        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "\033[" . $this->background_colors[$background_color] . "m";
        }

        // Add string and end coloring
        $colored_string .=  $string . "\033[0m";

        return ($colored_string);
    }
323413
public static function printColored ($string, $foreground_color = null, $background_color = null) {
		$colored_string = "";

		// Check if given foreground color found
		if (isset(Bartender::$foreground_colors[$foreground_color])) {
			$colored_string .= "\033[" . Bartender::$foreground_colors[$foreground_color] . "m";
		}
		// Check if given background color found
		if (isset(Bartender::$background_colors[$background_color])) {
			$colored_string .= "\033[" . Bartender::$background_colors[$background_color] . "m";
		}

		// Add string and end coloring
		$colored_string .=  $string;

		echo $colored_string;
	}
777474
public function convert($string)
    {
        $css = self::parse($string);
        $data = self::formatCssArray($css);
        $this->data = $data;
        return $data;
    }
651851
function make_styles_string($styles) {
        if (empty($styles)) {
            return null;
        }

        $string = '';
        foreach($styles as $property => $value) {
            $string .= $property . ':' . $value . ';';
        }
        return $string;
    }