Total Complexity | 13 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class ConfigInit |
||
8 | { |
||
9 | protected $length; |
||
10 | protected $segment; |
||
11 | protected $seperator; |
||
12 | protected $charset; |
||
13 | |||
14 | protected function runConfig($config_array=null) |
||
15 | { |
||
16 | if(empty($config_array)) |
||
17 | { |
||
18 | $this->setConfig(); |
||
19 | } else { |
||
20 | $this->directConfig($config_array); |
||
21 | } |
||
22 | } |
||
23 | |||
24 | private function setConfig() |
||
25 | { |
||
26 | if (function_exists('config') and function_exists('app')) {//Load Config For Laravel |
||
27 | if(!empty(config('irfa.serial_number'))) |
||
28 | { |
||
29 | $this->laravelConfig(); |
||
30 | } else{ |
||
31 | $this->generalConfig(); |
||
32 | } |
||
33 | } else{//Load Config for Non-Laravel |
||
34 | $this->generalConfig(); |
||
35 | } |
||
36 | } |
||
37 | private function laravelConfig() |
||
38 | { |
||
39 | $this->length = config('irfa.serial_number.length'); |
||
|
|||
40 | $this->segment = config('irfa.serial_number.segment'); |
||
41 | $this->seperator = config('irfa.serial_number.seperator'); |
||
42 | $this->charset = config('irfa.serial_number.charset'); |
||
43 | } |
||
44 | |||
45 | private function generalConfig() |
||
46 | { |
||
47 | require dirname(__DIR__, 2)."/config/config.php"; |
||
48 | |||
49 | $this->length = $config['length']; |
||
50 | $this->segment = $config['segment']; |
||
51 | $this->seperator = $config['seperator']; |
||
52 | $this->charset = $config['charset']; |
||
53 | } |
||
54 | |||
55 | private function directConfig($arr) |
||
63 | } |
||
64 | |||
65 | } |
||
66 | |||
67 |