Lang   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 91
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
B setConfig() 0 22 4
A getConfig() 0 6 1
A get() 0 8 1
A getNumbers() 0 15 2
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  __DIR__ . '/CalendarSettings/Jalali.php';
48
49
        /**
50
        * Fetch translated expression to langTable attribute
51
        */
52
        self::$langTable = include __DIR__ . '/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
74
        $file = include( __DIR__ . '/lang/' . $lang . '/general.php');
75
76
        return $file[$value];
77
78
    }
79
80
    /**
81
     * Translate numbers
82
     *
83
     * @param  integer $numbers
84
     * @return string
85
     */
86
    public static function getNumbers( $lang, $numbers )
87
    {
88
89
      $result = null;
90
91
      $file = include( __DIR__ . '/lang/' . $lang . '/general.php');
92
93
      foreach(  str_split( $numbers, 1 ) as $key => $value ) {
94
95
        $result .= $file[$value];
96
97
      }
98
      return $result;
99
100
    }
101
102
}
103