private function convertColor($hex, $alpha = false)
    {
        $hex = str_replace('#', '', $hex);
        $length = strlen($hex);
        $rgb['0'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
        $rgb['1'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
        $rgb['2'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
        if ($alpha) {
            $rgb['2'] = $alpha;
        }

        return $rgb;
    }
private function convertColor($hex, $alpha = false)
    {
        $hex = str_replace('#', '', $hex);
        $length = strlen($hex);
        $rgb['0'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
        $rgb['1'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
        $rgb['2'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
        if ($alpha) {
            $rgb['2'] = $alpha;
        }

        return $rgb;
    }
private function convertColor ( $ hex , $ alpha = false ) { $ hex = str_replace ( '#' , '' , $ hex ) ; $ length = strlen ( $ hex ) ; $ rgb [ '0' ] = hexdec ( $ length == 6 ? substr ( $ hex , 0 , 2 ) : ( $ length == 3 ? str_repeat ( substr ( $ hex , 0 , 1 ) , 2 ) : 0 ) ) ; $ rgb [ '1' ] = hexdec ( $ length == 6 ? substr ( $ hex , 2 , 2 ) : ( $ length == 3 ? str_repeat ( substr ( $ hex , 1 , 1 ) , 2 ) : 0 ) ) ; $ rgb [ '2' ] = hexdec ( $ length == 6 ? substr ( $ hex , 4 , 2 ) : ( $ length == 3 ? str_repeat ( substr ( $ hex , 2 , 1 ) , 2 ) : 0 ) ) ; if ( $ alpha ) { $ rgb [ '2' ] = $ alpha ; } return $ rgb ; }
Convert hexa color to rgb or rgba.

@param $hex Hexa color code.
$alpha (bool) either alpha append or not

@since 3.0.0

@return array
Convert hexa color to rgb or rgba .