Cml\Console\Format\Colour::charToCode PHP Method

charToCode() private static method

返回颜色对应的数字编码
private static charToCode ( integer | string | array $color ) : array
$color integer | string | array
return array
    private static function charToCode($color)
    {
        if (is_array($color)) {
            return $color;
        } else {
            if (is_string($color)) {
                list($color, $option) = explode('+', strtolower($color));
                if (!isset(self::$colors[$color])) {
                    throw new \InvalidArgumentException("Unknown color '{$color}'");
                }
                if ($option && !isset(self::$options[$option])) {
                    throw new \InvalidArgumentException("Unknown option '{$option}'");
                }
                $code = self::$colors[$color];
                $option = $option ? self::$options[$option] : 0;
                return [$code, $option];
            } else {
                return [$color, 0];
            }
        }
    }