Skip to content

Commit 2403f40

Browse files
author
Samuel Akopyan
committed
Added cleaning empty fileds on form submission
1 parent 27a096c commit 2403f40

File tree

2 files changed

+257
-219
lines changed

2 files changed

+257
-219
lines changed

framework/helpers/CString.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
* humanize
2020
* plural
2121
* isSerialized
22-
*
22+
* shortenUrl
23+
*
2324
*/
2425

2526
class CString
@@ -237,4 +238,17 @@ public static function isSerialized($string)
237238

238239
return false;
239240
}
241+
242+
/**
243+
* Returns shorten URL
244+
* @param string $url
245+
* @param int $len1
246+
* @param int $len2
247+
* @return string|string[]|null
248+
*/
249+
public static function shortenUrl($url = '', $len1 = 0, $len2 = 0)
250+
{
251+
return preg_replace("/(?<=.{{$len1}})(.+)(?=.{{$len2}})/", '...', $url);
252+
}
253+
240254
}

0 commit comments

Comments
 (0)