StripHtml::filter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2016 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/Filter/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Filter\FilterRule;
10
11
use Particle\Filter\FilterRule;
12
13
/**
14
 * Class StripHtml
15
 *
16
 * @package Particle\Filter\FilterRule
17
 */
18
class StripHtml extends FilterRule
19
{
20
    /**
21
     * @var string
22
     */
23
    protected $excludeTags;
24
25
    /**
26
     * Set tags that wont be stripped
27
     *
28
     * @param string|null $excludeTags
29
     */
30 4
    public function __construct($excludeTags = null)
31
    {
32 4
        $this->excludeTags = $excludeTags;
33 4
    }
34
35
    /**
36
     * Strip html tags from the value
37
     *
38
     * @param mixed $value
39
     * @return string
40
     */
41 4
    public function filter($value)
42
    {
43 4
        if ($value === null) {
44 1
            return $value;
45
        }
46
47 3
        return strip_tags($value, $this->excludeTags);
48
    }
49
}
50