Code Duplication    Length = 31-31 lines in 2 locations

class/oledrion_utils.php 1 location

@@ 1300-1330 (lines=31) @@
1297
     * @param $string
1298
     * @return string
1299
     */
1300
    public static function close_tags($string)
1301
    {
1302
        // match opened tags
1303
        if (preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $start_tags)) {
1304
            $start_tags = $start_tags[1];
1305
1306
            // match closed tags
1307
            if (preg_match_all('/<\/([a-z]+)>/', $string, $end_tags)) {
1308
                $complete_tags = array();
1309
                $end_tags      = $end_tags[1];
1310
1311
                foreach ($start_tags as $key => $val) {
1312
                    $posb = array_search($val, $end_tags);
1313
                    if (is_int($posb)) {
1314
                        unset($end_tags[$posb]);
1315
                    } else {
1316
                        $complete_tags[] = $val;
1317
                    }
1318
                }
1319
            } else {
1320
                $complete_tags = $start_tags;
1321
            }
1322
1323
            $complete_tags = array_reverse($complete_tags);
1324
            for ($i = 0, $iMax = count($complete_tags); $i < $iMax; ++$i) {
1325
                $string .= '</' . $complete_tags[$i] . '>';
1326
            }
1327
        }
1328
1329
        return $string;
1330
    }
1331
1332
    /**
1333
     * @param               $string

class/utility.php 1 location

@@ 1443-1473 (lines=31) @@
1440
     * @param $string
1441
     * @return string
1442
     */
1443
    public static function close_tags($string)
1444
    {
1445
        // match opened tags
1446
        if (preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $start_tags)) {
1447
            $start_tags = $start_tags[1];
1448
1449
            // match closed tags
1450
            if (preg_match_all('/<\/([a-z]+)>/', $string, $end_tags)) {
1451
                $complete_tags = array();
1452
                $end_tags      = $end_tags[1];
1453
1454
                foreach ($start_tags as $key => $val) {
1455
                    $posb = array_search($val, $end_tags);
1456
                    if (is_int($posb)) {
1457
                        unset($end_tags[$posb]);
1458
                    } else {
1459
                        $complete_tags[] = $val;
1460
                    }
1461
                }
1462
            } else {
1463
                $complete_tags = $start_tags;
1464
            }
1465
1466
            $complete_tags = array_reverse($complete_tags);
1467
            for ($i = 0, $iMax = count($complete_tags); $i < $iMax; ++$i) {
1468
                $string .= '</' . $complete_tags[$i] . '>';
1469
            }
1470
        }
1471
1472
        return $string;
1473
    }
1474
1475
    /**
1476
     * @param               $string