Completed
Branch dev (374206)
by James Ekow Abaka
06:04
created

Janitor::cleanHtml()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace ntentan\honam\engines\php;
4
5
/**
6
 * A class which contains methods for cleaning out contents and making them
7
 * safe.
8
 */
9
class Janitor
10
{
11
    /**
12
     * A utility method which either strips html tags or escapes them.
13
     *
14
     * @param string $string The string to be cleaned
15
     * @param boolean $strip When true the tags are stripped instead of being escaped.
16
     * @return string
17
     */
18
    public function cleanHtml($string, $strip = false)
19
    {
20
        if ($strip === false) {
21
            return htmlspecialchars((string)$string);
22
        } else {
23
            return strip_tags((string)$string);
24
        }
25
    }
26
}