Code Duplication    Length = 15-18 lines in 2 locations

src/CSS.php 1 location

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

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).