Passed
Pull Request — master (#4)
by Mark
01:22
created

syntax_plugin_description   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 8
eloc 15
c 4
b 1
f 0
dl 0
loc 42
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A connectTo() 0 3 1
A getSort() 0 3 1
A handle() 0 6 1
A getType() 0 3 1
A render() 0 12 3
A getPType() 0 3 1
1
<?php
2
3
/**
4
 * Description plugin.
5
 *
6
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
7
 * @author     Matthias Schulte <[email protected]>
8
 * @author     Mark C. Prins <[email protected]>
9
 *
10
 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
11
 * @noinspection AutoloadingIssuesInspection
12
 */
13
14
use dokuwiki\Extension\SyntaxPlugin;
1 ignored issue
show
Bug introduced by
The type dokuwiki\Extension\SyntaxPlugin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
class syntax_plugin_description extends SyntaxPlugin
17
{
18
    final  public function getType(): string
19
    {
20
        return 'substition';
21
    }
22
23
    final public function getPType(): string
24
    {
25
        return 'block';
26
    }
27
28
    final  public function getSort(): int
29
    {
30
        return 98;
31
    }
32
33
    final  public function connectTo($mode): void
34
    {
35
        $this->Lexer->addSpecialPattern('\{\{description>.+?\}\}', $mode, 'plugin_description');
36
    }
37
38
    final public function handle($match, $state, $pos, Doku_Handler $handler): array
1 ignored issue
show
Bug introduced by
The type Doku_Handler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
39
    {
40
        $match = substr($match, 14, -2); // strip markup
41
        $match = hsc($match);
42
43
        return [$match];
44
    }
45
46
    final public function render($format, Doku_Renderer $renderer, $data): bool
1 ignored issue
show
Bug introduced by
The type Doku_Renderer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
    {
48
        $description = $data[0];
49
        if (empty($description)) {
50
            return false;
51
        }
52
53
        if ($format === 'metadata') {
54
            $renderer->meta['plugin_description']['keywords'] = $description;
55
            return true;
56
        }
57
        return false;
58
    }
59
}
60