Total Complexity | 11 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Helper |
||
11 | { |
||
12 | public static function fixConfig(array $config): array |
||
28 | } |
||
29 | |||
30 | public static function exportDefines(array $defines): string |
||
31 | { |
||
32 | $res = ''; |
||
33 | foreach ($defines as $key => $value) { |
||
34 | $var = static::exportVar($value); |
||
35 | $res .= "defined('$key') or define('$key', $var);\n"; |
||
36 | } |
||
37 | |||
38 | return $res; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Returns PHP-executable string representation of given value. |
||
43 | * Uses Riimu/Kit-PHPEncoder based `var_export` alternative. |
||
44 | * And Opis/Closure to dump closures as PHP code. |
||
45 | * @param mixed $value |
||
46 | * @return string |
||
47 | * @throws \ReflectionException |
||
48 | */ |
||
49 | public static function exportVar($value): string |
||
50 | { |
||
51 | return static::getEncoder()->encode($value); |
||
52 | } |
||
53 | |||
54 | private static $encoder; |
||
55 | |||
56 | private static function getEncoder() |
||
63 | } |
||
64 | |||
65 | private static function createEncoder() |
||
73 | } |
||
74 | } |
||
75 |