Conditions | 5 |
Paths | 7 |
Total Lines | 26 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | static function parse($code) |
||
|
|||
8 | { |
||
9 | $configCode = extract_unit($code, "# START CONFIGURATION DO NOT REMOVE THIS LINE", "# END CONFIGURATION DO NOT REMOVE THIS LINE"); |
||
10 | $configCode = preg_replace('/[\t\n\r\0\x0B]/', '', $configCode); |
||
11 | $configCode = preg_replace('/([\s])\1+/', ' ', $configCode); |
||
12 | $configCode = explode(";", $configCode); |
||
13 | $configCode = array_map('trim', $configCode); |
||
14 | $result = []; |
||
15 | foreach ($configCode as &$code) { |
||
16 | $key = substr($code, 0, strpos($code, ' = ')); |
||
17 | $key = str_replace('$this->', '', $key); |
||
18 | $val = substr($code, strpos($code, ' = ') + 3); |
||
19 | $val = trim(str_replace("'", '"', $val), '"'); |
||
20 | if (strtolower($val) == "true") { |
||
21 | $val = true; |
||
22 | } elseif (strtolower($val) == "false") { |
||
23 | $val = false; |
||
24 | } |
||
25 | if ($key == "") { |
||
26 | continue; |
||
27 | } |
||
28 | |||
29 | $result[$key] = $val; |
||
30 | } |
||
31 | |||
32 | return $result; |
||
33 | } |
||
34 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.