public static function textColorFor($color_string) { $color = Static::colorHexToDec($color_string); $black = [0, 0, 0]; $white = [256, 256, 256]; $blackTextPoints = 0; $whiteTextPoints = 0; Static::colorDiff($color, $black) == 'true' ? ++$blackTextPoints : --$blackTextPoints; Static::colorDiff($color, $white) == 'true' ? ++$whiteTextPoints : --$whiteTextPoints; Static::brightDiff($color, $black) == 'true' ? ++$blackTextPoints : --$blackTextPoints; Static::brightDiff($color, $white) == 'true' ? ++$whiteTextPoints : --$whiteTextPoints; Static::lumDiff($color, $black) == 'true' ? ++$blackTextPoints : --$blackTextPoints; Static::lumDiff($color, $white) == 'true' ? ++$whiteTextPoints : --$whiteTextPoints; Static::pythDiff($color, $black) == 'true' ? ++$blackTextPoints : --$blackTextPoints; Static::pythDiff($color, $white) == 'true' ? ++$whiteTextPoints : --$whiteTextPoints; return $blackTextPoints > $whiteTextPoints ? "black" : "white"; }