Beans_Lessc::coerceColor PHP Метод

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

coerce a value for use in color operation
protected coerceColor ( $value )
    protected function coerceColor($value)
    {
        switch ($value[0]) {
            case 'color':
                return $value;
            case 'raw_color':
                $c = array("color", 0, 0, 0);
                $colorStr = substr($value[1], 1);
                $num = hexdec($colorStr);
                $width = strlen($colorStr) == 3 ? 16 : 256;
                for ($i = 3; $i > 0; $i--) {
                    // 3 2 1
                    $t = $num % $width;
                    $num /= $width;
                    $c[$i] = $t * (256 / $width) + $t * floor(16 / $width);
                }
                return $c;
            case 'keyword':
                $name = $value[1];
                if (isset(self::$cssColors[$name])) {
                    $rgba = explode(',', self::$cssColors[$name]);
                    if (isset($rgba[3])) {
                        return array('color', $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
                    }
                    return array('color', $rgba[0], $rgba[1], $rgba[2]);
                }
                return null;
        }
    }