Passed
Push — feature/6.x ( 53903f...32797a )
by Schlaefer
05:38 queued 02:15
created

BbcodeQuotePostprocessor   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Saito - The Threaded Web Forum
6
 *
7
 * @copyright Copyright (c) the Saito Project Developers
8
 * @link https://github.com/Schlaefer/Saito
9
 * @license http://opensource.org/licenses/MIT
10
 */
11
12
namespace BbcodeParser\Lib\Processors;
13
14
class BbcodeQuotePostprocessor extends BbcodeProcessor
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19
    public function process($string)
20
    {
21
        $quoteSymbolSanitized = h($this->_sOptions->get('quote_symbol'));
22
        $string = preg_replace(
23
            // Begin of the text or a new line in the text, maybe one space afterwards
24
            '/(^|\n\r\s?)' .
25
            $quoteSymbolSanitized .
26
            '\s(.*)(?!\<br)/m',
27
            "\\1<span class=\"richtext-citation\">" . $quoteSymbolSanitized . " \\2</span>",
28
            $string
29
        );
30
31
        return $string;
32
    }
33
}
34