]> source.dussan.org Git - nextcloud-server.git/commitdiff
add php-doc for ellipsis
authorJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 12 Nov 2012 13:04:23 +0000 (14:04 +0100)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Mon, 12 Nov 2012 13:04:23 +0000 (14:04 +0100)
lib/helper.php

index 5a93e6533de7edf87364ef326fcd5cbf35e41f1c..02e36d601d2e35c62b9ee60f0b69050750668a6f 100644 (file)
@@ -712,8 +712,14 @@ class OC_Helper {
 
                return false;
        }
-       
 
+       /**
+        * Shortens str to maxlen by replacing characters in the middle with '...', eg.
+        * ellipsis('a very long string with lots of useless info to make a better example', 14) becomes 'a very ...example'
+        * @param string $str the string
+        * @param string $maxlen the maximum length of the result
+        * @return string with at most maxlen characters
+        */
        public static function ellipsis($str, $maxlen) {
                if (strlen($str) > $maxlen) {
                        $characters = floor($maxlen / 2);
@@ -721,5 +727,5 @@ class OC_Helper {
                }
                return $str;
        }
-       
+
 }