Passed
Push — v3 ( dc00fa...37cdd6 )
by
unknown
02:41
created

Str   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 28
ccs 2
cts 4
cp 0.5
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isoToUtf8() 0 3 1
A utf8ToIso() 0 3 1
1
<?php
2
/**
3
 * This file is part of GameQ.
4
 *
5
 * GameQ is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * GameQ is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace GameQ\Helpers;
20
21
/**
22
 * This helper contains functions to work with strings.
23
 *
24
 * @package GameQ\Helpers
25
 */
26
class Str
27
{
28
    /**
29
     * This helper method re-encodes an ISO 8859-1 string to UTF-8.
30
     *
31
     * @see https://en.wikipedia.org/wiki/ISO/IEC_8859-1
32
     * @see https://en.wikipedia.org/wiki/UTF-8
33
     *
34
     * @param string $value The ISO 8859-1 encoded string.
35
     * @return string The UTF-8 encoded string.
36
     */
37 528
    public static function isoToUtf8($value)
38
    {
39 528
        return iconv('ISO-8859-1', 'UTF-8', $value);
40
    }
41
42
    /**
43
     * This helper method re-encodes an UTF-8 string to ISO 8859-1.
44
     *
45
     * @see https://en.wikipedia.org/wiki/ISO/IEC_8859-1
46
     * @see https://en.wikipedia.org/wiki/UTF-8
47
     *
48
     * @param string $value The UTF-8 encoded string.
49
     * @return string  The ISO 8859-1 encoded string.
50
     */
51
    public static function utf8ToIso($value)
52
    {
53
        return iconv('UTF-8', 'ISO-8859-1', $value);
54
    }
55
}
56