Code Duplication    Length = 35-37 lines in 2 locations

src/Compilers/ShortcodeCompiler.php 2 locations

@@ 284-320 (lines=37) @@
281
     * @author Wordpress
282
     * @return string
283
     */
284
    protected function getRegex()
285
    {
286
        // Get shortcode names
287
        $shortcodeNames = $this->getShortcodeNames();
288
289
        // return regex
290
        return "/"
291
        . '\\['                              // Opening bracket
292
        . '(\\[?)'                           // 1: Optional second opening bracket for escaping laravel-shortcodes: [[tag]]
293
        . "($shortcodeNames)"                // 2: Shortcode name
294
        . '(?![\\w-])'                       // Not followed by word character or hyphen
295
        . '('                                // 3: Unroll the loop: Inside the opening shortcode tag
296
        . '[^\\]\\/]*'                   // Not a closing bracket or forward slash
297
        . '(?:'
298
        . '\\/(?!\\])'               // A forward slash not followed by a closing bracket
299
        . '[^\\]\\/]*'               // Not a closing bracket or forward slash
300
        . ')*?'
301
        . ')'
302
        . '(?:'
303
        . '(\\/)'                        // 4: Self closing tag ...
304
        . '\\]'                          // ... and closing bracket
305
        . '|'
306
        . '\\]'                          // Closing bracket
307
        . '(?:'
308
        . '('                        // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags
309
        . '[^\\[]*+'             // Not an opening bracket
310
        . '(?:'
311
        . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag
312
        . '[^\\[]*+'         // Not an opening bracket
313
        . ')*+'
314
        . ')'
315
        . '\\[\\/\\2\\]'             // Closing shortcode tag
316
        . ')?'
317
        . ')'
318
        . '(\\]?)'                         // 6: Optional second closing brocket for escaping laravel-shortcodes: [[tag]]
319
        . "/s";
320
    }
321
322
    private function getStripRegex()
323
    {
@@ 322-356 (lines=35) @@
319
        . "/s";
320
    }
321
322
    private function getStripRegex()
323
    {
324
        // Get shortcode names
325
        $shortcodeNames = $this->getShortcodeNames();
326
327
        return
328
            '\\['                       // Opening bracket
329
            . '(\\[?)'                  // 1: Optional second opening bracket for escaping shortcodes: [[tag]]
330
            . "($shortcodeNames)"            // 2: Shortcode name
331
            . '(?![\\w-])'              // Not followed by word character or hyphen
332
            . '('                       // 3: Unroll the loop: Inside the opening shortcode tag
333
            . '[^\\]\\/]*'              // Not a closing bracket or forward slash
334
            . '(?:'
335
            . '\\/(?!\\])'              // A forward slash not followed by a closing bracket
336
            . '[^\\]\\/]*'              // Not a closing bracket or forward slash
337
            . ')*?'
338
            . ')'
339
            . '(?:'
340
            . '(\\/)'                   // 4: Self closing tag ...
341
            . '\\]'                     // ... and closing bracket
342
            . '|'
343
            . '\\]'                     // Closing bracket
344
            . '(?:'
345
            . '('                       // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags
346
            . '[^\\[]*+'                // Not an opening bracket
347
            . '(?:'
348
            . '\\[(?!\\/\\2\\])'        // An opening bracket not followed by the closing shortcode tag
349
            . '[^\\[]*+'                // Not an opening bracket
350
            . ')*+'
351
            . ')'
352
            . '\\[\\/\\2\\]'            // Closing shortcode tag
353
            . ')?'
354
            . ')'
355
            . '(\\]?)';                 // 6: Optional second closing brocket for escaping shortcodes: [[tag]]
356
    }
357
358
    /**
359
     * Remove all shortcode tags from the given content.