Test Failed
Push — feature-laravel-5.4 ( 2b4b90...5bfdc4 )
by Kirill
03:52
created

RawTextRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 8 1
A removeDisallowedTags() 0 10 1
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Services\ContentRenderer;
12
13
/**
14
 * Class RawTextRenderer.
15
 */
16
class RawTextRenderer extends MarkdownRenderer
17
{
18
    /**
19
     * @param string $body
20
     * @return string
21
     */
22
    public function render(string $body): string
23
    {
24
        $result = parent::render($body);
25
26
        $result = $this->removeDisallowedTags($result);
27
28
        return $result;
29
    }
30
31
    /**
32
     * @param string $body
33
     * @return string
34
     */
35
    private function removeDisallowedTags(string $body): string
36
    {
37
        return strip_tags($body, [
38
            'b', 'strong',      // bold
39
            'i', 'em',          // italic
40
            'ul', 'li', 'ol',   // list
41
            'a',                // link
42
            'code', 'pre'       // code
43
        ]);
44
    }
45
}
46