Passed
Push — master ( be6e91...b708f5 )
by Joël
03:06 queued 14s
created

gettext_helper.php ➔ _n()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
1 ignored issue
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 20 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
// @codeCoverageIgnoreStart
3
defined('BASEPATH') || exit('No direct script access allowed');
4
// @codeCoverageIgnoreEnd
5
6
/**
7
 * CodeIgniter Gettext Helpers
8
 *
9
 * @package        CodeIgniter
10
 * @subpackage    Helpers
11
 * @category    Gettext
12
 * @author        Joël Gaujard <[email protected]>
13
 */
14
15
if (!function_exists('__')) {
16
    /**
17
     * @param string $expression
18
     * @return string
19
     */
20
    function __($expression)
21
    {
22 6
        return (gettext($expression));
23
    }
24
}
25
26
if (!function_exists('_e')) {
27
    /**
28
     * @param string $expression
29
     */
30
    function _e($expression)
31
    {
32 2
        echo (__($expression));
33 2
    }
34
}
35
36
if (!function_exists('_n')) {
37
    /**
38
     * @param $expression_singular
39
     * @param $expression_plural
40
     * @param $number
41
     * @return string
42
     */
43
    function _n($expression_singular, $expression_plural, $number)
44
    {
45 2
        return (ngettext($expression_singular, $expression_plural, (int)$number));
46
    }
47
}