Code Duplication    Length = 15-18 lines in 2 locations

class/Utility.php 1 location

@@ 1496-1513 (lines=18) @@
1493
     * @param  bool         $break_words
1494
     * @return mixed|string
1495
     */
1496
public static function truncateTagSafe($string, $length = 80, $etc = '...', $break_words = false)
1497
{
1498
    if ($length == 0) {
1499
        return '';
1500
    }
1501
    if (strlen($string) > $length) {
1502
        $length -= strlen($etc);
1503
        if (!$break_words) {
1504
            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
1505
            $string = preg_replace('/<[^>]*$/', '', $string);
1506
            $string = LexikonUtility::closeTags($string);
1507
        }
1508
1509
        return $string . $etc;
1510
    } else {
1511
        return $string;
1512
    }
1513
}
1514
1515
    /**
1516
     * @return array

include/functions.php 1 location

@@ 1035-1049 (lines=15) @@
1032
 *           <amos dot robinson at gmail dot com>
1033
 * used in Block entries_scrolling.php
1034
 */
1035
function lx_truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false) {
1036
    if ($length == 0) return '';
1037
    if (strlen($string) > $length) {
1038
        $length -= strlen($etc);
1039
        if (!$break_words) {
1040
            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
1041
            $string = preg_replace('/<[^>]*$/', '', $string);
1042
            $string = lx_close_tags($string);
1043
        }
1044
1045
        return $string . $etc;
1046
    } else {
1047
        return $string;
1048
    }
1049
}
1050
1051
function lexikon_summary() {
1052
global $xoopsDB;