src/Utilities/Colors/Color.php
private static function parseHexComponents($str)
    {
        $len = strlen($str);

        $r = $g = $b = $a = null;

        if ($len === 6 || $len === 8) {
            $r = hexdec($str[0].$str[1]);
            $g = hexdec($str[2].$str[3]);
            $b = hexdec($str[4].$str[5]);
            $a = $len === 8 ? hexdec($str[6].$str[7]) : 255;
        } elseif ($len === 3 || $len == 4) {
            $r = hexdec($str[0].$str[0]);
            $g = hexdec($str[1].$str[1]);
            $b = hexdec($str[2].$str[2]);
            $a = $len === 4 ? hexdec($str[3].$str[3]) : 255;
        }

        return array($r, $g, $b, $a);
    }
private static function parseHexComponents($str)
    {
        $len = strlen($str);

        $r = $g = $b = $a = null;

        if ($len === 6 || $len === 8) {
            $r = hexdec($str[0].$str[1]);
            $g = hexdec($str[2].$str[3]);
            $b = hexdec($str[4].$str[5]);
            $a = $len === 8 ? hexdec($str[6].$str[7]) : 255;
        } elseif ($len === 3 || $len == 4) {
            $r = hexdec($str[0].$str[0]);
            $g = hexdec($str[1].$str[1]);
            $b = hexdec($str[2].$str[2]);
            $a = $len === 4 ? hexdec($str[3].$str[3]) : 255;
        }

        return array($r, $g, $b, $a);
    }
private static function parseHexComponents ( $ str ) { $ len = strlen ( $ str ) ; $ r = $ g = $ b = $ a = null ; if ( $ len === 6 || $ len === 8 ) { $ r = hexdec ( $ str [ 0 ] . $ str [ 1 ] ) ; $ g = hexdec ( $ str [ 2 ] . $ str [ 3 ] ) ; $ b = hexdec ( $ str [ 4 ] . $ str [ 5 ] ) ; $ a = $ len === 8 ? hexdec ( $ str [ 6 ] . $ str [ 7 ] ) : 255 ; } elseif ( $ len === 3 || $ len == 4 ) { $ r = hexdec ( $ str [ 0 ] . $ str [ 0 ] ) ; $ g = hexdec ( $ str [ 1 ] . $ str [ 1 ] ) ; $ b = hexdec ( $ str [ 2 ] . $ str [ 2 ] ) ; $ a = $ len === 4 ? hexdec ( $ str [ 3 ] . $ str [ 3 ] ) : 255 ; } return array ( $ r , $ g , $ b , $ a ) ; }
Takes a hex string of length 3, 4, 6 or 8 and converts it into an array
of floating-point RGBA components.

For strings of invalid length, all components will be null.

@param string $str The hexadecimal color string to convert.

@return float[] The RGBA components (0 - 255).
Takes a hex string of length 3 4 6 or 8 and converts it into an array of floating - point RGBA components .