1 | <?php |
||
18 | abstract class Generator |
||
19 | { |
||
20 | /** |
||
21 | * Formats array into form parsable by php. |
||
22 | * Why not just var_export? Because output is hard to read and debug. |
||
23 | * |
||
24 | * @param array $data Array to be formatted |
||
25 | * @return string Formatted string |
||
26 | */ |
||
27 | protected function formatArray(array $data) |
||
28 | { |
||
29 | $pairs = []; |
||
30 | foreach ($data as $key => $value) { |
||
31 | $pairs[] = sprintf( |
||
32 | '%s => %s', |
||
33 | var_export($key, true), |
||
34 | var_export($value, true) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | return '['.implode(', ', $pairs).']'; |
||
39 | } |
||
40 | |||
41 | abstract public function generate($className); |
||
42 | } |
||
43 |