+ /**
+ * Checks, if the given string is a valid hexadecimal code
+ *
+ * @param string $hexCode
+ *
+ * @return bool
+ */
+ public static function isHex($hexCode)
+ {
+ return !empty($hexCode) ? @preg_match("/^[a-f0-9]{2,}$/i", $hexCode) && !(strlen($hexCode) & 1) : false;
+ }
+