Completed
Push — develop ( cf888c...411996 )
by Fabian
9s
created

HtmlEncoder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A encode() 0 6 2
A getFlags() 0 4 1
1
<?php
2
3
namespace Fabfuel\Prophiler\Toolbar\Formatter\Encoder;
4
5
class HtmlEncoder implements EncoderInterface
6
{
7
8
    /**
9
     * @var string
10
     */
11
    protected $encoding;
12
13
    /**
14
     * @param string $encoding
15
     */
16 5
    public function __construct($encoding = '')
17
    {
18 5
        $this->encoding = $encoding;
19 5
    }
20
21
    /**
22
     * @param string $encode
23
     *
24
     * @return string
25
     */
26 5
    public function encode($encode)
27
    {
28 5
        return is_string($encode)
29 5
            ? htmlentities($encode, static::getFlags(), '', false)
30 5
            : $encode;
31
    }
32
33
    /**
34
     * @return int
35
     */
36 2
    protected static function getFlags()
37
    {
38 2
        return ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE;
39
    }
40
}
41