44
55namespace PhpStringHelpers \utility ;
66
7+ use src \exceptions \UrlIsNotValidException ;
8+ use src \exceptions \FileDoesNotExistsException ;
9+
710class StrUtility
811{
912 const REGULAR_WORDS_PATTERN = '/[^a-z0-9]/im ' ;
@@ -85,13 +88,11 @@ public static function translate(string $key, string $replace = '', string $file
8588 $ filePath = self ::path ('lang. ' . $ fileName );
8689
8790 if (!is_file ($ filePath ) || !file_exists ($ filePath ))
88- // throw new FileDoesNotExistsException("file does not exist");
89- return 'no found ' ;
91+ throw new FileDoesNotExistsException ("File Does Not Exist " );
9092
9193 $ data = require_once $ filePath ;
9294
9395 if (!is_array ($ data ))
94- // throw file data is not array ...
9596 $ data = [];
9697
9798 if (!key_exists ($ key , $ data ))
@@ -115,8 +116,7 @@ public static function path(string $path, string $pathExtension = 'php'): string
115116 $ filePath = $ path . '. ' . strtolower ($ pathExtension );
116117
117118 if (!is_file ($ filePath ) || !file_exists ($ filePath ))
118- // throw new FileDoesNotExistsException("file does not exist");
119- return 'no found ' ;
119+ throw new FileDoesNotExistsException ("File Does Not Exist " );
120120
121121 return $ filePath ;
122122 }
@@ -242,8 +242,8 @@ public static function generateAnchor(string|int $content, string $href): string
242242 $ href = filter_var (trim ($ href ), FILTER_SANITIZE_URL );
243243
244244 if (!filter_var ($ href , FILTER_VALIDATE_URL ))
245- // throw exception
246- return " url is not valid " ;
245+ throw new UrlIsNotValidException ( ' Url Is Not Valid ' );
246+
247247 return "<a href= $ href> " . self ::clearString ($ content ) . '</a> ' ;
248248 }
249249
0 commit comments