Leafo\ScssPhp\Compiler::coerceColor PHP Method

coerceColor() protected method

Coerce value to color
protected coerceColor ( array $value ) : array | null
$value array
return array | null
    protected function coerceColor($value)
    {
        switch ($value[0]) {
            case Type::T_COLOR:
                return $value;
            case Type::T_KEYWORD:
                $name = strtolower($value[1]);
                if (isset(Colors::$cssColors[$name])) {
                    $rgba = explode(',', Colors::$cssColors[$name]);
                    return isset($rgba[3]) ? [Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2], (int) $rgba[3]] : [Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2]];
                }
                return null;
        }
        return null;
    }
Compiler