Code Duplication    Length = 15-18 lines in 2 locations

class/Utility.php 1 location

@@ 1470-1487 (lines=18) @@
1467
     * @param  bool         $break_words
1468
     * @return mixed|string
1469
     */
1470
public static function truncateTagSafe($string, $length = 80, $etc = '...', $break_words = false)
1471
{
1472
    if ($length == 0) {
1473
        return '';
1474
    }
1475
    if (strlen($string) > $length) {
1476
        $length -= strlen($etc);
1477
        if (!$break_words) {
1478
            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
1479
            $string = preg_replace('/<[^>]*$/', '', $string);
1480
            $string = LexikonUtility::closeTags($string);
1481
        }
1482
1483
        return $string . $etc;
1484
    } else {
1485
        return $string;
1486
    }
1487
}
1488
1489
    /**
1490
     * @return array

include/functions.php 1 location

@@ 883-897 (lines=15) @@
880
 *           <amos dot robinson at gmail dot com>
881
 * used in Block entries_scrolling.php
882
 */
883
function lx_truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false) {
884
    if ($length == 0) return '';
885
    if (strlen($string) > $length) {
886
        $length -= strlen($etc);
887
        if (!$break_words) {
888
            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
889
            $string = preg_replace('/<[^>]*$/', '', $string);
890
            $string = lx_close_tags($string);
891
        }
892
893
        return $string . $etc;
894
    } else {
895
        return $string;
896
    }
897
}
898
899
function lexikon_summary() {
900
global $xoopsDB;