Code Duplication    Length = 15-18 lines in 2 locations

src/JS.php 1 location

@@ 196-213 (lines=18) @@
193
    /**
194
     * Strip comments from source code.
195
     */
196
    protected function stripComments()
197
    {
198
        // PHP only supports $this inside anonymous functions since 5.4
199
        $minifier = $this;
200
        $callback = function ($match) use ($minifier) {
201
            $count = count($minifier->extracted);
202
            $placeholder = '/*'.$count.'*/';
203
            $minifier->extracted[$placeholder] = $match[0];
204
205
            return $placeholder;
206
        };
207
        // multi-line comments
208
        $this->registerPattern('/\n?\/\*(!|.*?@license|.*?@preserve).*?\*\/\n?/s', $callback);
209
        $this->registerPattern('/\/\*.*?\*\//s', '');
210
211
        // single-line comments
212
        $this->registerPattern('/\/\/.*$/m', '');
213
    }
214
215
    /**
216
     * JS can have /-delimited regular expressions, like: /ab+c/.match(string).

src/CSS.php 1 location

@@ 632-646 (lines=15) @@
629
    /**
630
     * Strip comments from source code.
631
     */
632
    protected function stripComments()
633
    {
634
        // PHP only supports $this inside anonymous functions since 5.4
635
        $minifier = $this;
636
        $callback = function ($match) use ($minifier) {
637
            $count = count($minifier->extracted);
638
            $placeholder = '/*'.$count.'*/';
639
            $minifier->extracted[$placeholder] = $match[0];
640
641
            return $placeholder;
642
        };
643
        $this->registerPattern('/\n?\/\*(!|.*?@license|.*?@preserve).*?\*\/\n?/s', $callback);
644
645
        $this->registerPattern('/\/\*.*?\*\//s', '');
646
    }
647
648
    /**
649
     * Strip whitespace.