Passed
Push — feature/6.x ( 53903f...32797a )
by Schlaefer
05:38 queued 02:15
created

CodeWithoutAttributes::_parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 3
dl 0
loc 18
rs 9.9666
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Saito - The Threaded Web Forum
6
 *
7
 * @copyright Copyright (c) the Saito Project Developers
8
 * @link https://github.com/Schlaefer/Saito
9
 * @license http://opensource.org/licenses/MIT
10
 */
11
12
namespace BbcodeParser\Lib\jBBCode\Definitions;
13
14
//@codingStandardsIgnoreStart
15
class CodeWithoutAttributes extends CodeDefinition
16
//@codingStandardsIgnoreEnd
17
{
18
    protected $_sTagName = 'code';
19
20
    protected $_sParseContent = false;
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    protected function _parse($content, $attributes, \JBBCode\ElementNode $node)
26
    {
27
        $type = 'text';
28
        if (!empty($attributes['code'])) {
29
            $type = $attributes['code'];
30
        }
31
32
        $this->Geshi->defaultLanguage = 'text';
0 ignored issues
show
Bug Best Practice introduced by
The property Geshi does not exist on BbcodeParser\Lib\jBBCode...s\CodeWithoutAttributes. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
        // allow all languages
34
        $this->Geshi->validLanguages = [true];
35
        // load config from app/Config/geshi.php
36
        $this->Geshi->features = false;
37
38
        $string = '<div class="geshi-wrapper"><pre lang="' . $type . '">' . $content . '</pre></div>';
39
40
        $string = $this->Geshi->highlight($string);
0 ignored issues
show
Bug introduced by
The method highlight() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        /** @scrutinizer ignore-call */ 
41
        $string = $this->Geshi->highlight($string);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
42
        return $string;
43
    }
44
}
45
46
//@codingStandardsIgnoreStart
47
class CodeWithAttributes extends CodeWithoutAttributes
48
//@codingStandardsIgnoreEnd
49
{
50
    protected $_sUseOptions = true;
51
}
52