Completed
Pull Request — master (#127)
by
unknown
02:01
created

translator_functions.php ➔ noop__()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Gettext\BaseTranslator;
4
5
/**
6
 * Returns the translation of a string.
7
 *
8
 * @param string $original
9
 *
10
 * @return string
11
 */
12
function __($original)
13
{
14
    $text = BaseTranslator::$current->gettext($original);
15
16
    if (func_num_args() === 1) {
17
        return $text;
18
    }
19
20
    $args = array_slice(func_get_args(), 1);
21
22
    return vsprintf($text, is_array($args[0]) ? $args[0] : $args);
23
}
24
25
/**
26
 * Noop, marks the string for translation but returns it unchanged.
27
 *
28
 * @param string $original
29
 *
30
 * @return string
31
 */
32
function noop__($original)
33
{
34
    return $original;
35
}
36
37
/**
38
 * Returns the singular/plural translation of a string.
39
 *
40
 * @param string $original
41
 * @param string $plural
42
 * @param string $value
43
 *
44
 * @return string
45
 */
46 View Code Duplication
function n__($original, $plural, $value)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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.
61
 *
62
 * @param string $context
63
 * @param string $original
64
 *
65
 * @return string
66
 */
67 View Code Duplication
function p__($context, $original)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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.
82
 *
83
 * @param string $domain
84
 * @param string $original
85
 *
86
 * @return string
87
 */
88 View Code Duplication
function d__($domain, $original)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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.
103
 *
104
 * @param string $domain
105
 * @param string $context
106
 * @param string $original
107
 *
108
 * @return string
109
 */
110 View Code Duplication
function dp__($domain, $context, $original)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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.
125
 *
126
 * @param string $context
127
 * @param string $original
128
 * @param string $plural
129
 * @param string $value
130
 *
131
 * @return string
132
 */
133 View Code Duplication
function np__($context, $original, $plural, $value)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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.
148
 *
149
 * @param string $domain
150
 * @param string $context
151
 * @param string $original
152
 * @param string $plural
153
 * @param string $value
154
 *
155
 * @return string
156
 */
157 View Code Duplication
function dnp__($domain, $context, $original, $plural, $value)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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