@@ -45,7 +45,7 @@ class Helper
4545 * @param string $ext
4646 * @return mixed|null
4747 */
48- public static function getImageMime ($ ext )
48+ public static function getImageMime (string $ ext )
4949 {
5050 return self ::$ imgMimeTypes [$ ext ] ?? null ;
5151 }
@@ -54,7 +54,7 @@ public static function getImageMime($ext)
5454 * @param string $mime
5555 * @return mixed|null
5656 */
57- public static function getImageExtByMime ($ mime )
57+ public static function getImageExtByMime (string $ mime )
5858 {
5959 $ key = array_search ($ mime , self ::$ imgMimeTypes , true );
6060
@@ -65,19 +65,19 @@ public static function getImageExtByMime($mime)
6565 * @param string $file
6666 * @return string eg: 'image/gif'
6767 */
68- public static function getMimeType ($ file )
68+ public static function getMimeType (string $ file )
6969 {
7070 // return mime_content_type($file);
7171 return finfo_file (finfo_open (FILEINFO_MIME_TYPE ), $ file );
7272 }
7373
7474 /**
75- * @param $string
75+ * @param string $string
7676 * @param string $delimiter
7777 * @param bool $filterEmpty
7878 * @return array
7979 */
80- public static function explode ($ string , $ delimiter = ', ' , $ filterEmpty = true )
80+ public static function explode (string $ string , string $ delimiter = ', ' , $ filterEmpty = true )
8181 {
8282 $ string = trim ($ string , $ delimiter );
8383
@@ -95,7 +95,7 @@ public static function explode($string, $delimiter = ',', $filterEmpty = true)
9595 * @param string $encoding
9696 * @return int
9797 */
98- public static function strlen ($ str , $ encoding = 'UTF-8 ' )
98+ public static function strlen (string $ str , $ encoding = 'UTF-8 ' )
9999 {
100100 $ str = html_entity_decode ($ str , ENT_COMPAT , 'UTF-8 ' );
101101
@@ -108,12 +108,12 @@ public static function strlen($str, $encoding = 'UTF-8')
108108
109109 /**
110110 * @param $str
111- * @return bool| string
111+ * @return string
112112 */
113113 public static function strToLower ($ str )
114114 {
115115 if (\is_array ($ str )) {
116- return false ;
116+ return '' ;
117117 }
118118
119119 if (\function_exists ('mb_strtolower ' )) {
@@ -124,15 +124,11 @@ public static function strToLower($str)
124124 }
125125
126126 /**
127- * @param $str
128- * @return bool| string
127+ * @param string $str
128+ * @return string
129129 */
130- public static function strToUpper ($ str )
130+ public static function strToUpper (string $ str )
131131 {
132- if (\is_array ($ str )) {
133- return false ;
134- }
135-
136132 if (\function_exists ('mb_strtoupper ' )) {
137133 return mb_strtoupper ($ str , 'utf-8 ' );
138134 }
@@ -193,19 +189,19 @@ public static function strrpos($str, $find, $offset = 0, $encoding = 'utf-8')
193189 }
194190
195191 /**
196- * @param $str
192+ * @param string $str
197193 * @return string
198194 */
199- public static function ucfirst ($ str )
195+ public static function ucfirst (string $ str )
200196 {
201197 return self ::strToUpper (self ::subStr ($ str , 0 , 1 )) . self ::subStr ($ str , 1 );
202198 }
203199
204200 /**
205- * @param $str
201+ * @param string $str
206202 * @return string
207203 */
208- public static function ucwords ($ str )
204+ public static function ucwords (string $ str )
209205 {
210206 if (\function_exists ('mb_convert_case ' )) {
211207 return mb_convert_case ($ str , MB_CASE_TITLE );
@@ -221,7 +217,7 @@ public static function ucwords($str)
221217 * @param bool $upperCaseFirstChar
222218 * @return mixed
223219 */
224- public static function toCamelCase ($ str , $ upperCaseFirstChar = false )
220+ public static function toCamelCase (string $ str , $ upperCaseFirstChar = false )
225221 {
226222 $ str = self ::strToLower ($ str );
227223
@@ -240,7 +236,7 @@ public static function toCamelCase($str, $upperCaseFirstChar = false)
240236 * @param string $sep
241237 * @return string
242238 */
243- public static function toSnakeCase ($ string , $ sep = '_ ' )
239+ public static function toSnakeCase (string $ string , string $ sep = '_ ' )
244240 {
245241 // 'CMSCategories' => 'cms_categories'
246242 // 'RangePrice' => 'range_price'
@@ -251,7 +247,7 @@ public static function toSnakeCase($string, $sep = '_')
251247 * @param string $field
252248 * @return mixed|string
253249 */
254- public static function beautifyFieldName ($ field )
250+ public static function beautifyFieldName (string $ field )
255251 {
256252 $ str = self ::toSnakeCase ($ field , ' ' );
257253
0 commit comments