@@ -34,6 +34,12 @@ class Tame{
3434 */
3535 protected const GB = 1024 * self ::MB ;
3636
37+ /**
38+ * Salter String
39+ * @var string
40+ */
41+ private const PBKDF2_SALT = "\x2d\xb7\x68\x1a" ;
42+
3743
3844 /**
3945 * Echo `json_encode` with response and message
@@ -47,6 +53,22 @@ static public function echoJson(int $response = 0, string $message = 'null')
4753 echo json_encode (['response ' => $ response , 'message ' => $ message ]);
4854 }
4955
56+ /**
57+ * Check if Class Exists
58+ *
59+ * @param string $class
60+ * @param callable $function
61+ * @return mixed
62+ */
63+ static public function class_exists ($ class , callable $ function )
64+ {
65+ if (class_exists ($ class )){
66+ if (is_callable ($ function )){
67+ $ function ();
68+ }
69+ }
70+ }
71+
5072 /**
5173 * PHP Version Compare
5274 *
@@ -609,10 +631,35 @@ static public function removeSpecialChars(?string $string = null)
609631 return null ;
610632 }
611633
612- // Remove anything that's not a letter, number, or whitespace
613- $ clean = preg_replace ('/[^\p{L}\p{N}\s]/u ' , '' , $ string );
634+ return self ::cleanTagsForURL ($ string );
635+ }
636+
637+ /**
638+ * Clean tags for use in URLs, considering multiple language modules.
639+ *
640+ * @param string|null $string The input string to clean.
641+ * @return string The cleaned string.
642+ */
643+ static public function cleanTagsForURL (?string $ string = null )
644+ {
645+ // Remove unwanted characters from the string
646+ $ string = preg_replace ('/[^\p{L}\p{N}\s]/u ' , '' , (string ) $ string );
647+
648+ return trim ($ string );
649+ }
614650
615- return $ clean ;
651+ /**
652+ * Hash String
653+ *
654+ * @param string $string
655+ * @param int $length
656+ * @param string $type
657+ * @param int $interation
658+ * @return void
659+ */
660+ static public function stringHash (?string $ string = null , $ length = 100 , $ type = 'sha256 ' , $ interation = 100 )
661+ {
662+ return hash_pbkdf2 ($ type , mt_rand () . $ string , self ::PBKDF2_SALT , $ interation , $ length );
616663 }
617664
618665 /**
@@ -641,20 +688,6 @@ static public function shortenString($string = null, $limit = 50, $replacer = '.
641688 return $ string ;
642689 }
643690
644- /**
645- * Clean tags for use in URLs, considering multiple language modules.
646- *
647- * @param string|null $string The input string to clean.
648- * @return string The cleaned string.
649- */
650- static public function cleanTagsForURL (?string $ string = null )
651- {
652- // Remove unwanted characters from the string
653- $ string = preg_replace ('/[^\p{L}\p{N}\s]/u ' , '' , (string ) $ string );
654-
655- return trim ($ string );
656- }
657-
658691 /**
659692 * Decode entity html strings
660693 *
0 commit comments