Failed Conditions
Push — psr2 ( e9eace...d4d8fb )
by Andreas
14:17 queued 07:54
created

Filelink   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A preConnect() 0 12 1
A connectTo() 0 8 1
A getSort() 0 4 1
1
<?php
2
3
namespace dokuwiki\Parsing\ParserMode;
4
5
class Filelink extends AbstractMode
6
{
7
8
    protected $pattern;
9
10
    /** @inheritdoc */
11
    public function preConnect()
12
    {
13
14
        $ltrs = '\w';
15
        $gunk = '/\#~:.?+=&%@!\-';
16
        $punc = '.:?\-;,';
17
        $host = $ltrs.$punc;
0 ignored issues
show
Unused Code introduced by
$host is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
18
        $any  = $ltrs.$gunk.$punc;
19
20
        $this->pattern = '\b(?i)file(?-i)://['.$any.']+?['.
21
            $punc.']*[^'.$any.']';
22
    }
23
24
    /** @inheritdoc */
25
    public function connectTo($mode)
26
    {
27
        $this->Lexer->addSpecialPattern(
28
            $this->pattern,
29
            $mode,
30
            'filelink'
31
        );
32
    }
33
34
    /** @inheritdoc */
35
    public function getSort()
36
    {
37
        return 360;
38
    }
39
}
40