Code Duplication    Length = 38-38 lines in 2 locations

install/cli-install.php 1 location

@@ 1826-1863 (lines=38) @@
1823
    }
1824
}
1825
1826
if (!function_exists('removeDocblock')) {
1827
    /**
1828
     * Remove installer Docblock only from components using plugin FileSource / fileBinding
1829
     *
1830
     * @param string $code
1831
     * @param string $type
1832
     * @return string
1833
     */
1834
    function removeDocblock($code, $type)
1835
    {
1836
1837
        $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1838
1839
        // Procedure taken from plugin.filesource.php
1840
        switch ($type) {
1841
            case 'snippet':
1842
                $elm_name = 'snippets';
1843
                $include = 'return require';
1844
                $count = 47;
1845
                break;
1846
1847
            case 'plugin':
1848
                $elm_name = 'plugins';
1849
                $include = 'require';
1850
                $count = 39;
1851
                break;
1852
1853
            default:
1854
                return $cleaned;
1855
        };
1856
        if (substr(trim($cleaned), 0, $count) == $include . ' MODX_BASE_PATH.\'assets/' . $elm_name . '/') {
1857
            return $cleaned;
1858
        }
1859
1860
        // fileBinding not found - return code incl docblock
1861
        return $code;
1862
    }
1863
}
1864

install/src/functions.php 1 location

@@ 713-750 (lines=38) @@
710
    }
711
}
712
713
if (!function_exists('removeDocblock')) {
714
    /**
715
     * Remove installer Docblock only from components using plugin FileSource / fileBinding
716
     *
717
     * @param string $code
718
     * @param string $type
719
     * @return string
720
     */
721
    function removeDocblock($code, $type)
722
    {
723
724
        $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
725
726
        // Procedure taken from plugin.filesource.php
727
        switch ($type) {
728
            case 'snippet':
729
                $elm_name = 'snippets';
730
                $include = 'return require';
731
                $count = 47;
732
                break;
733
734
            case 'plugin':
735
                $elm_name = 'plugins';
736
                $include = 'require';
737
                $count = 39;
738
                break;
739
740
            default:
741
                return $cleaned;
742
        };
743
        if (substr(trim($cleaned), 0, $count) == $include . ' MODX_BASE_PATH.\'assets/' . $elm_name . '/') {
744
            return $cleaned;
745
        }
746
747
        // fileBinding not found - return code incl docblock
748
        return $code;
749
    }
750
}
751