Completed
Pull Request — develop (#59)
by
unknown
05:37
created

HtmlEncoder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Fabfuel\Prophiler\Toolbar\Formatter\Encoder;
4
5
class HtmlEncoder implements EncoderInterface
6
{
7
8
    const ENCODER_FLAGS = ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE;
9
10
    /**
11
     * @var string
12
     */
13
    protected $encoding;
14
15
    /**
16
     * @param string $encoding
17
     */
18
    public function __construct($encoding = '')
19
    {
20
        $this->encoding = $encoding;
21
    }
22
23
    /**
24
     * @param string $encode
25
     *
26
     * @return string
27
     */
28
    public function encode($encode)
29
    {
30
        return is_string($encode)
31
            ? htmlentities($encode, static::ENCODER_FLAGS, '', false)
32
            : $encode;
33
    }
34
35
}
36