GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 165ce3...e10afb )
by Shea
9s
created

onBeforeParse()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.2
c 0
b 0
f 0
cc 4
eloc 11
nc 1
nop 1
1
<?php
2
3
class ShortcodableShortcodeParserExtension extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    public function onBeforeParse(&$content)
6
    {
7
        $parser = $this->owner;
8
        // Check the shortcode type and convert wrapper to div if block type
9
        // Regex examples: https://regex101.com/r/bFtD9o/3
10
        $content = preg_replace_callback(
11
            '|<p( [^>]*?)?>\s*?\[((.*)([\s,].*)?)\]\s*?</p>|U',
12
            function ($matches) use($parser) {
13
                $shortcodeName = $matches[3];
14
                // Since we're only concerned with shortcodable objects we know the
15
                // shortcode name will be the class name so don't have to look it up
16
                return ($shortcodeName && $parser->registered($shortcodeName)
17
                    && Config::inst()->get($shortcodeName, 'shortcodable_is_block'))
18
                    ? "<div$matches[1]>[$matches[2]]</div>"
19
                    : $matches[0];
20
            },
21
            $content
22
        );
23
    }
24
}
25