public static function getContrastYIQ($hexColor): string
    {
        $hexColor = str_replace('#', '', $hexColor);

        $r   = hexdec(substr($hexColor, 0, 2));
        $g   = hexdec(substr($hexColor, 2, 2));
        $b   = hexdec(substr($hexColor, 4, 2));
        $yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;

        return ($yiq >= 128) ? 'black' : 'white';
    }
public static function getContrastYIQ($hexColor): string
    {
        $hexColor = str_replace('#', '', $hexColor);

        $r   = hexdec(substr($hexColor, 0, 2));
        $g   = hexdec(substr($hexColor, 2, 2));
        $b   = hexdec(substr($hexColor, 4, 2));
        $yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;

        return ($yiq >= 128) ? 'black' : 'white';
    }
public static function getContrastYIQ ( $ hexColor ) : string { $ hexColor = str_replace ( '#' , '' , $ hexColor ) ; $ r = hexdec ( substr ( $ hexColor , 0 , 2 ) ) ; $ g = hexdec ( substr ( $ hexColor , 2 , 2 ) ) ; $ b = hexdec ( substr ( $ hexColor , 4 , 2 ) ) ; $ yiq = ( ( $ r * 299 ) + ( $ g * 587 ) + ( $ b * 114 ) ) / 1000 ; return ( $ yiq >= 128 ) ? 'black' : 'white' ; }
Determines if the contrasting color to be used based on a HEX color code

@param string $hexColor

@return string
Determines if the contrasting color to be used based on a HEX color code