Colors\Color::stylize PHP Method

stylize() protected method

protected stylize ( $style, $text )
    protected function stylize($style, $text)
    {
        if (!$this->shouldStylize()) {
            return $text;
        }
        $style = strtolower($style);
        if ($this->isUserStyleExists($style)) {
            return $this->applyUserStyle($style, $text);
        }
        if ($this->isStyleExists($style)) {
            return $this->applyStyle($style, $text);
        }
        if (preg_match('/^((?:bg_)?)color\\[([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\]$/', $style, $matches)) {
            $option = $matches[1] == 'bg_' ? 48 : 38;
            return $this->buildEscSeq("{$option};5;{$matches[2]}") . $text . $this->buildEscSeq($this->styles['reset']);
        }
        throw new NoStyleFoundException("Invalid style {$style}");
    }