Failed Conditions
Push — psr2 ( de3699...36dc94 )
by Andreas
06:50 queued 03:31
created

Entity::preConnect()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 3
dl 0
loc 10
c 0
b 0
f 0
cc 4
eloc 6
nop 0
rs 9.2
1
<?php
2
3
namespace dokuwiki\ParserMode;
4
5
class Entity extends AbstractMode
6
{
7
8
    protected $entities = array();
9
    protected $pattern = '';
10
11
    /**
12
     * Entity constructor.
13
     * @param string[] $entities
14
     */
15
    public function __construct($entities)
16
    {
17
        $this->entities = $entities;
18
    }
19
20
21
    /** @inheritdoc */
22
    public function preConnect()
23
    {
24
        if (!count($this->entities) || $this->pattern != '') return;
25
26
        $sep = '';
27
        foreach ($this->entities as $entity) {
28
            $this->pattern .= $sep.Doku_Lexer_Escape($entity);
29
            $sep = '|';
30
        }
31
    }
32
33
    /** @inheritdoc */
34
    public function connectTo($mode)
35
    {
36
        if (!count($this->entities)) return;
37
38
        if (strlen($this->pattern) > 0) {
39
            $this->Lexer->addSpecialPattern($this->pattern, $mode, 'entity');
40
        }
41
    }
42
43
    /** @inheritdoc */
44
    public function getSort()
45
    {
46
        return 260;
47
    }
48
}
49