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

Entity   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A preConnect() 0 10 4
A connectTo() 0 8 3
A getSort() 0 4 1
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