strToASCII()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 78
Code Lines 75

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 75
c 1
b 0
f 1
dl 0
loc 78
ccs 0
cts 2
cp 0
rs 8.5454
cc 1
nc 1
nop 1
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
if (!function_exists('fix_input_quotes')) {
4
    /**
5
     * @deprecated use of get_magic_quotes_gpc is deprecated
6
     */
7
    function fix_input_quotes()
8
    {
9
//        if (get_magic_quotes_gpc()) {
10
//            array_stripslashes($_GET);
11
//            array_stripslashes($_POST);
12
//            array_stripslashes($_COOKIE);
13
//        }
14
    }
15
}
16
17
if (!function_exists('array_stripslashes')) {
18
    function array_stripslashes(&$array)
19
    {
20
        if (!is_array($array)) {
21
            return;
22
        }
23
        foreach ($array as $k => $v) {
24
            if (is_array($array[$k])) {
25
                array_stripslashes($array[$k]);
26
            } else {
27
                $array[$k] = stripslashes($array[$k]);
28
            }
29
        }
30
        return $array;
31
    }
32
}
33
34
if (!function_exists('clean')) {
35
    function clean($input)
36
    {
37
        return trim(stripslashes(htmlentities($input, ENT_QUOTES, 'UTF-8')));
38
    }
39
}
40
41
if (!function_exists('strToASCII')) {
42
    function strToASCII($str)
43
    {
44
        $trans = [
45
            'Š' => 'S',
46
            'Ș' => 'S',
47
            'š' => 's',
48
            'ș' => 's',
49
            'Ð' => 'Dj',
50
            'Ž' => 'Z',
51
            'ž' => 'z',
52
            'À' => 'A',
53
            'Á' => 'A',
54
            'Â' => 'A',
55
            'Ã' => 'A',
56
            'Ä' => 'A',
57
            'Ă' => 'A',
58
            'Å' => 'A',
59
            'Æ' => 'A',
60
            'Ç' => 'C',
61
            'È' => 'E',
62
            'É' => 'E',
63
            'Ê' => 'E',
64
            'Ë' => 'E',
65
            'Ì' => 'I',
66
            'Í' => 'I',
67
            'Î' => 'I',
68
            'Ï' => 'I',
69
            'Ñ' => 'N',
70
            'Ò' => 'O',
71
            'Ó' => 'O',
72
            'Ô' => 'O',
73
            'Õ' => 'O',
74
            'Ö' => 'O',
75
            'Ø' => 'O',
76
            'Ù' => 'U',
77
            'Ú' => 'U',
78
            'Ț' => 'T',
79
            'Û' => 'U',
80
            'Ü' => 'U',
81
            'Ý' => 'Y',
82
            'Þ' => 'B',
83
            'ß' => 'Ss',
84
            'à' => 'a',
85
            'á' => 'a',
86
            'â' => 'a',
87
            'ã' => 'a',
88
            'ä' => 'a',
89
            'ă' => 'a',
90
            'å' => 'a',
91
            'æ' => 'a',
92
            'ç' => 'c',
93
            'è' => 'e',
94
            'é' => 'e',
95
            'ê' => 'e',
96
            'ë' => 'e',
97
            'ì' => 'i',
98
            'í' => 'i',
99
            'î' => 'i',
100
            'ï' => 'i',
101
            'ð' => 'o',
102
            'ñ' => 'n',
103
            'ò' => 'o',
104
            'ó' => 'o',
105
            'ô' => 'o',
106
            'õ' => 'o',
107
            'ö' => 'o',
108
            'ø' => 'o',
109
            'ù' => 'u',
110
            'ú' => 'u',
111
            'û' => 'u',
112
            'ý' => 'y',
113
            'ý' => 'y',
114
            'þ' => 'b',
115
            'ÿ' => 'y',
116
            'ƒ' => 'f',
117
            'ț' => 't'
118
        ];
119
        return strtr($str, $trans);
120
    }
121
}
122
123
if (!function_exists('value')) {
124
    /**
125
     * Return the default value of the given value.
126
     *
127
     * @param  mixed $value
128
     * @return mixed
129
     */
130
    function value($value)
131
    {
132
        return $value instanceof Closure ? $value() : $value;
133
    }
134
}
135