Contao\StyleSheets::convertHexColor PHP Метод

convertHexColor() защищенный Метод

Convert hex colors to rgb
См. также: http://de3.php.net/manual/de/function.hexdec.php#99478
protected convertHexColor ( string $color, boolean $blnWriteToFile = false, array $vars = [] ) : array
$color string
$blnWriteToFile boolean
$vars array
Результат array
    protected function convertHexColor($color, $blnWriteToFile = false, $vars = array())
    {
        // Support global variables
        if (strncmp($color, '$', 1) === 0) {
            if (!$blnWriteToFile) {
                return array($color);
            } else {
                $color = str_replace(array_keys($vars), array_values($vars), $color);
            }
        }
        $rgb = array();
        // Try to convert using bitwise operation
        if (strlen($color) == 6) {
            $dec = hexdec($color);
            $rgb['red'] = 0xff & $dec >> 0x10;
            $rgb['green'] = 0xff & $dec >> 0x8;
            $rgb['blue'] = 0xff & $dec;
        } elseif (strlen($color) == 3) {
            $rgb['red'] = hexdec(str_repeat(substr($color, 0, 1), 2));
            $rgb['green'] = hexdec(str_repeat(substr($color, 1, 1), 2));
            $rgb['blue'] = hexdec(str_repeat(substr($color, 2, 1), 2));
        }
        return $rgb;
    }