Code Duplication    Length = 12-12 lines in 6 locations

src/translator_functions.php 6 locations

@@ 46-57 (lines=12) @@
43
 *
44
 * @return string
45
 */
46
function n__($original, $plural, $value)
47
{
48
    $text = BaseTranslator::$current->ngettext($original, $plural, $value);
49
50
    if (func_num_args() === 3) {
51
        return $text;
52
    }
53
54
    $args = array_slice(func_get_args(), 3);
55
56
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
57
}
58
59
/**
60
 * Returns the translation of a string in a specific context.
@@ 67-78 (lines=12) @@
64
 *
65
 * @return string
66
 */
67
function p__($context, $original)
68
{
69
    $text = BaseTranslator::$current->pgettext($context, $original);
70
71
    if (func_num_args() === 2) {
72
        return $text;
73
    }
74
75
    $args = array_slice(func_get_args(), 2);
76
77
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
78
}
79
80
/**
81
 * Returns the translation of a string in a specific domain.
@@ 88-99 (lines=12) @@
85
 *
86
 * @return string
87
 */
88
function d__($domain, $original)
89
{
90
    $text = BaseTranslator::$current->dgettext($domain, $original);
91
92
    if (func_num_args() === 2) {
93
        return $text;
94
    }
95
96
    $args = array_slice(func_get_args(), 2);
97
98
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
99
}
100
101
/**
102
 * Returns the translation of a string in a specific domain and context.
@@ 110-121 (lines=12) @@
107
 *
108
 * @return string
109
 */
110
function dp__($domain, $context, $original)
111
{
112
    $text = BaseTranslator::$current->dpgettext($domain, $context, $original);
113
114
    if (func_num_args() === 3) {
115
        return $text;
116
    }
117
118
    $args = array_slice(func_get_args(), 3);
119
120
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
121
}
122
123
/**
124
 * Returns the singular/plural translation of a string in a specific context.
@@ 133-144 (lines=12) @@
130
 *
131
 * @return string
132
 */
133
function np__($context, $original, $plural, $value)
134
{
135
    $text = BaseTranslator::$current->npgettext($context, $original, $plural, $value);
136
137
    if (func_num_args() === 4) {
138
        return $text;
139
    }
140
141
    $args = array_slice(func_get_args(), 4);
142
143
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
144
}
145
146
/**
147
 * Returns the singular/plural translation of a string in a specific domain and context.
@@ 157-168 (lines=12) @@
154
 *
155
 * @return string
156
 */
157
function dnp__($domain, $context, $original, $plural, $value)
158
{
159
    $text = BaseTranslator::$current->dnpgettext($domain, $context, $original, $plural, $value);
160
161
    if (func_num_args() === 5) {
162
        return $text;
163
    }
164
165
    $args = array_slice(func_get_args(), 5);
166
167
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
168
}
169
170