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

ShortcodableShortcodeParserExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBeforeParse() 0 19 4
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