Code Duplication    Length = 18-18 lines in 2 locations

class/utility.php 1 location

@@ 887-904 (lines=18) @@
884
     *
885
     * @return string
886
     */
887
    public static function truncateTagSafe($string, $length = 80, $etc = '...', $break_words = false)
888
    {
889
        if (0 == $length) {
890
            return '';
891
        }
892
        if (strlen($string) > $length) {
893
            $length -= strlen($etc);
894
            if (!$break_words) {
895
                $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
896
                $string = preg_replace('/<[^>]*$/', '', $string);
897
                $string = static::closeTags($string);
898
            }
899
900
            return $string . $etc;
901
        } else {
902
            return $string;
903
        }
904
    }
905
906
    /**
907
     * Resize a Picture to some given dimensions (using the wideImage library)

include/functions.php 1 location

@@ 765-782 (lines=18) @@
762
 *
763
 * @return string
764
 */
765
function news_truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false)
766
{
767
    if (0 == $length) {
768
        return '';
769
    }
770
    if (strlen($string) > $length) {
771
        $length -= strlen($etc);
772
        if (!$break_words) {
773
            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
774
            $string = preg_replace('/<[^>]*$/', '', $string);
775
            $string = news_close_tags($string);
776
        }
777
778
        return $string . $etc;
779
    } else {
780
        return $string;
781
    }
782
}
783
784
/**
785
 * Resize a Picture to some given dimensions (using the wideImage library)