Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class Helper |
||
13 | { |
||
14 | /** |
||
15 | * Returns PHP-executable string representation of given value. |
||
16 | * Uses Riimu/Kit-PHPEncoder based `var_export` alternative. |
||
17 | * And Opis/Closure to dump closures as PHP code. |
||
18 | * |
||
19 | * @param mixed $value |
||
20 | * |
||
21 | * @throws \ReflectionException |
||
22 | * |
||
23 | * @return string |
||
24 | */ |
||
25 | 24 | public static function exportVar($value): string |
|
26 | { |
||
27 | 24 | return static::getEncoder()->encode($value); |
|
28 | } |
||
29 | |||
30 | private static ?PHPEncoder $encoder = null; |
||
31 | |||
32 | 24 | private static function getEncoder(): PHPEncoder |
|
39 | } |
||
40 | |||
41 | 2 | private static function createEncoder(): PHPEncoder |
|
52 | } |
||
53 | } |
||
54 |