Completed
Push — master ( 78b5e2...1285a5 )
by Marcus
04:22
created

Windows1252ToUtf8::filter()   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
 * Filter to convert Windows 1252 to UTF-8 encoding
4
 *
5
 * @author    Marcus Jaschen <[email protected]>
6
 * @license   http://www.opensource.org/licenses/mit-license MIT License
7
 * @link      https://github.com/mjaschen/collmex
8
 */
9
10
namespace MarcusJaschen\Collmex\Filter;
11
12
use ForceUTF8\Encoding;
13
14
/**
15
 * Filter to convert Windows 1252 to UTF-8 encoding
16
 *
17
 * @author   Marcus Jaschen <[email protected]>
18
 * @license  http://www.opensource.org/licenses/mit-license MIT License
19
 * @link     https://github.com/mjaschen/collmex
20
 */
21
class Windows1252ToUtf8 implements FilterInterface
22
{
23
    /**
24
     * @param string $input string or array
25
     *
26
     * @return string
27
     *
28
     * @deprecated
29
     */
30
    public function filter($input)
31
    {
32
        return Encoding::toUTF8($input);
33
    }
34
35
    /**
36
     * @param string $text
37
     *
38
     * @return string
39
     */
40
    public function filterString($text)
41
    {
42
        return Encoding::toUTF8($text);
43
    }
44
45
    /**
46
     * @param array $input
47
     *
48
     * @return array
49
     */
50
    public function filterArray(array $input)
51
    {
52
        // The Encoding methods are array-aware so we can just drop our input
53
        // into the conversion method.
54
55
        return (array)Encoding::toUTF8($input);
56
    }
57
}
58