Total Complexity | 4 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | class markup extends base |
||
14 | { |
||
15 | /** @var array Data array of regex patterns */ |
||
16 | protected $data; |
||
17 | |||
18 | /** |
||
19 | * @inheritdoc |
||
20 | */ |
||
21 | 28 | public function run() |
|
22 | { |
||
23 | 28 | return $this->set_data()->process(); |
|
24 | } |
||
25 | |||
26 | /** |
||
27 | * @inheritdoc |
||
28 | */ |
||
29 | 28 | public function set_data() |
|
30 | { |
||
31 | 28 | if (!isset($this->data)) |
|
32 | 28 | { |
|
33 | // RegEx patterns originally based on Topic Text Hover Mod by RMcGirr83 |
||
34 | 28 | $this->data = array( |
|
35 | 28 | '#<!-- [lmw] --><a class="postlink[^>]*>(.*<\/a[^>]*>)?<!-- [lmw] -->#Usi', // Magic URLs |
|
36 | 28 | '#<[^>]*>(.*<[^>]*>)?#Usi', // HTML code |
|
37 | 28 | '#\[/?[^\[\]]+\]#mi', // All BBCode tags |
|
38 | 28 | '#(http|https|ftp|mailto)(:|\&\#58;)\/\/[^\s]+#i', // Remaining URLs |
|
39 | 28 | '#"#', // Possible un-encoded quotes from older board conversions |
|
40 | '#[ \t]{2,}#' // Multiple spaces #[\s]+# |
||
41 | 28 | ); |
|
42 | 28 | } |
|
43 | |||
44 | 28 | return $this; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Remove markup from the text |
||
49 | * |
||
50 | * @return string Stripped message text |
||
51 | */ |
||
52 | 28 | protected function process() |
|
55 | } |
||
56 | } |
||
57 |