| 1 | <?php |
||
| 15 | class CodeGenerator { |
||
| 16 | |||
| 17 | protected $config; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var GeneratorStrategy |
||
| 21 | */ |
||
| 22 | protected $strategy; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * |
||
| 26 | * @param CodeGeneratorConfig|array $config |
||
| 27 | */ |
||
| 28 | 10 | public function __construct($config = null) { |
|
| 29 | 10 | if (is_array($config)) { |
|
| 30 | 9 | $this->config = new CodeGeneratorConfig($config); |
|
| 31 | 1 | } else if ($config instanceof CodeGeneratorConfig) { |
|
| 32 | $this->config = $config; |
||
| 33 | } else { |
||
| 34 | 1 | $this->config = new CodeGeneratorConfig(); |
|
| 35 | } |
||
| 36 | |||
| 37 | 10 | $this->init(); |
|
| 38 | 10 | } |
|
| 39 | |||
| 40 | 16 | protected function init() { |
|
| 44 | |||
| 45 | /** |
||
| 46 | * Returns the used configuration |
||
| 47 | * |
||
| 48 | * @return CodeGeneratorConfig |
||
| 49 | */ |
||
| 50 | public function getConfig() { |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Returns the used generator strategy |
||
| 56 | * |
||
| 57 | * @return DefaultGeneratorStrategy |
||
| 58 | */ |
||
| 59 | public function getGeneratorStrategy() { |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Generates code from a given model |
||
| 65 | * |
||
| 66 | * @param GenerateableInterface $model |
||
| 67 | * @return string the generated code |
||
| 68 | */ |
||
| 69 | 16 | public function generate(GenerateableInterface $model) { |
|
| 76 | |||
| 77 | } |
||
| 78 |