CSSmin::rgb_to_hex PHP Метод

rgb_to_hex() приватный Метод

private rgb_to_hex ( $matches )
    private function rgb_to_hex($matches)
    {
        // Support for percentage values rgb(100%, 0%, 45%);
        if ($this->index_of($matches[1], '%') >= 0) {
            $rgbcolors = explode(',', str_replace('%', '', $matches[1]));
            for ($i = 0; $i < count($rgbcolors); $i++) {
                $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55);
            }
        } else {
            $rgbcolors = explode(',', $matches[1]);
        }
        // Values outside the sRGB color space should be clipped (0-255)
        for ($i = 0; $i < count($rgbcolors); $i++) {
            $rgbcolors[$i] = $this->clamp_number(intval($rgbcolors[$i], 10), 0, 255);
            $rgbcolors[$i] = sprintf("%02x", $rgbcolors[$i]);
        }
        // Fix for issue #2528093
        if (!preg_match('/[\\s\\,\\);\\}]/', $matches[2])) {
            $matches[2] = ' ' . $matches[2];
        }
        return '#' . implode('', $rgbcolors) . $matches[2];
    }