Completed
Push — master ( 3c8880...e2c218 )
by Dmitry
06:42 queued 02:46
created

Lang   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A t() 0 5 2
A lang() 0 4 1
A translate() 0 9 3
1
<?php
2
3
/*
4
 * HiPanel core package
5
 *
6
 * @link      https://hipanel.com/
7
 * @package   hipanel-core
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hipanel\base;
13
14
use Yii;
15
16
/**
17
 * AHnames Lang to Yii2 i18n conversion.
18
 */
19
class Lang
20
{
21
    /**
22
     * AHNAMES Lang to Yii2 i18n.
23
     * @param null $txt
0 ignored issues
show
Bug introduced by
There is no parameter named $txt. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
24
     * @param string $path
25
     *
26
     * @return string
27
     */
28
    public static function t($str = null, $path = 'app')
29
    {
30
        $res = self::lang($str, $path);
31
        return $res === $str ? Yii::t($str, $path) : $res;
32
    }
33
34
    public static function lang($txt = null, $path = 'app')
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
35
    {
36
        return preg_replace_callback('/{(lang):([^}]*)}/i', ['hipanel\base\Lang', 'translate'], $txt);
37
    }
38
39
    public static function translate($a, $path = 'app')
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        $str = $a[2];
42
        $res = Yii::t('app', $str);
43
        if (ctype_upper($str[0]) || ctype_upper($a[1][0])) {
44
            $res = ucfirst($res);
45
        }
46
        return $res;
47
    }
48
}
49