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

Utf8ToWindows1252   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A filter() 0 4 1
A filterString() 0 4 1
A filterArray() 0 4 1
1
<?php
2
/**
3
 * Filter to convert UTF-8 to Windows 1252 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 UTF-8 to Windows 1252 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 Utf8ToWindows1252 implements FilterInterface
22
{
23
    /**
24
     * @param string $input string or array
25
     *
26
     * @return string
27
     */
28
    public function filter($input)
29
    {
30
        return Encoding::toWin1252($input);
31
    }
32
33
    /**
34
     * @param string $text
35
     *
36
     * @return string
37
     */
38
    public function filterString($text)
39
    {
40
        return Encoding::toWin1252($text);
41
    }
42
43
    /**
44
     * @param array $input
45
     *
46
     * @return array
47
     */
48
    public function filterArray(array $input)
49
    {
50
        return (array)Encoding::toWin1252($input);
51
    }
52
}
53