Code Duplication    Length = 19-19 lines in 2 locations

class/oledrion_utils.php 1 location

@@ 1339-1357 (lines=19) @@
1336
     * @param  bool         $break_words
1337
     * @return mixed|string
1338
     */
1339
    public static function truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false)
1340
    {
1341
        if ($length == 0) {
1342
            return '';
1343
        }
1344
1345
        if (strlen($string) > $length) {
1346
            $length -= strlen($etc);
1347
            if (!$break_words) {
1348
                $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
1349
                $string = preg_replace('/<[^>]*$/', '', $string);
1350
                $string = static::close_tags($string);
1351
            }
1352
1353
            return $string . $etc;
1354
        } else {
1355
            return $string;
1356
        }
1357
    }
1358
1359
    /**
1360
     * Create an infotip

class/utility.php 1 location

@@ 1482-1500 (lines=19) @@
1479
     * @param  bool         $break_words
1480
     * @return mixed|string
1481
     */
1482
    public static function truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false)
1483
    {
1484
        if ($length == 0) {
1485
            return '';
1486
        }
1487
1488
        if (strlen($string) > $length) {
1489
            $length -= strlen($etc);
1490
            if (!$break_words) {
1491
                $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
1492
                $string = preg_replace('/<[^>]*$/', '', $string);
1493
                $string = self::close_tags($string);
1494
            }
1495
1496
            return $string . $etc;
1497
        } else {
1498
            return $string;
1499
        }
1500
    }
1501
1502
    /**
1503
     * Create an infotip