Completed
Push — master ( 3848cb...1f8425 )
by mehdi
02:54
created

Lang   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 6
c 4
b 0
f 2
lcom 1
cbo 0
dl 0
loc 67
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B setConfig() 0 22 4
A getConfig() 0 6 1
A get() 0 7 1
1
<?php namespace OpenCafe\Tools;
2
3
/************************************************************
4
 * Lang class tranlate every expresion according to lang
5
 ************************************************************
6
 *
7
 * table in lang folder
8
 * @since Aug, 21 2015
9
 *
10
 *\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
11
 */
12
class Lang
13
{
14
15
    /**
16
     * Store language table
17
     *
18
     * @var array
19
     */
20
    protected static $langTable;
21
22
    /**
23
     * Language translated words
24
     *
25
     * @var array
26
     */
27
    protected static $config;
28
29
    protected static $obj;
30
31
    /************************************************************
32
     * Return translated expression
33
     ************************************************************
34
     *
35
     * @since Aug, 21 2015
36
     * @param text string
37
     * @return mixed
38
     *
39
     *\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
40
     */
41
    public static function setConfig($language)
42
    {
43
44
        /**
45
       * Fetch translated file to config attribute
46
       */
47
        self::$config = include 'src/CalendarSettings/Jalali.php';
48
49
        /**
50
        * Fetch translated expression to langTable attribute
51
        */
52
        self::$langTable = include 'lang/' . $language . '/general.php';
53
54
        foreach (self::$langTable as $key => $translate) {
55
            if (isset(self::$config[ $key ])) {
56
                if (self::$config[ $key ]) {
57
                    self::$config[ $key ] = $translate;
58
                }
59
            }
60
        }
61
62
    }
63
64
    public static function getConfig()
65
    {
66
67
        return self::$config;
68
69
    }
70
71
    public static function get( $lang, $value ) {
72
73
      $file = include( 'lang/' . $lang . '/general.php' );
74
75
      return $file[$value];
76
77
    }
78
}
79