Add function for converting strings to color codes

This commit is contained in:
Joshua Ramon Enslin 2020-12-11 14:01:41 +01:00
parent 287fb02f8c
commit 34c2d57e5b
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -465,4 +465,18 @@ final class MD_STD {
return \levenshtein($str1, $str2); return \levenshtein($str1, $str2);
} }
/**
* Converts a string to color codes.
*
* @param string $str Input string.
*
* @return string
*/
public static function string_to_color_code(string $str):string {
$code = substr(dechex(crc32($str)), 0, 6);
return $code;
}
} }