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

Janitor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A cleanHtml() 0 8 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
}