Code Duplication    Length = 12-12 lines in 6 locations

src/translator_functions.php 6 locations

@@ 34-45 (lines=12) @@
31
 *
32
 * @return string
33
 */
34
function n__($original, $plural, $value)
35
{
36
    $text = BaseTranslator::$current->ngettext($original, $plural, $value);
37
38
    if (func_num_args() === 3) {
39
        return $text;
40
    }
41
42
    $args = array_slice(func_get_args(), 3);
43
44
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
45
}
46
47
/**
48
 * Returns the translation of a string in a specific context.
@@ 55-66 (lines=12) @@
52
 *
53
 * @return string
54
 */
55
function p__($context, $original)
56
{
57
    $text = BaseTranslator::$current->pgettext($context, $original);
58
59
    if (func_num_args() === 2) {
60
        return $text;
61
    }
62
63
    $args = array_slice(func_get_args(), 2);
64
65
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
66
}
67
68
/**
69
 * Returns the translation of a string in a specific domain.
@@ 76-87 (lines=12) @@
73
 *
74
 * @return string
75
 */
76
function d__($domain, $original)
77
{
78
    $text = BaseTranslator::$current->dgettext($domain, $original);
79
80
    if (func_num_args() === 2) {
81
        return $text;
82
    }
83
84
    $args = array_slice(func_get_args(), 2);
85
86
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
87
}
88
89
/**
90
 * Returns the translation of a string in a specific domain and context.
@@ 98-109 (lines=12) @@
95
 *
96
 * @return string
97
 */
98
function dp__($domain, $context, $original)
99
{
100
    $text = BaseTranslator::$current->dpgettext($domain, $context, $original);
101
102
    if (func_num_args() === 3) {
103
        return $text;
104
    }
105
106
    $args = array_slice(func_get_args(), 3);
107
108
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
109
}
110
111
/**
112
 * Returns the singular/plural translation of a string in a specific context.
@@ 121-132 (lines=12) @@
118
 *
119
 * @return string
120
 */
121
function np__($context, $original, $plural, $value)
122
{
123
    $text = BaseTranslator::$current->npgettext($context, $original, $plural, $value);
124
125
    if (func_num_args() === 4) {
126
        return $text;
127
    }
128
129
    $args = array_slice(func_get_args(), 4);
130
131
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
132
}
133
134
/**
135
 * Returns the singular/plural translation of a string in a specific domain and context.
@@ 145-156 (lines=12) @@
142
 *
143
 * @return string
144
 */
145
function dnp__($domain, $context, $original, $plural, $value)
146
{
147
    $text = BaseTranslator::$current->dnpgettext($domain, $context, $original, $plural, $value);
148
149
    if (func_num_args() === 5) {
150
        return $text;
151
    }
152
153
    $args = array_slice(func_get_args(), 5);
154
155
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
156
}
157
158
/**
159
 * Prints function result