| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | trait MakeController{ |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @param $module |
||
| 11 | * @param $filename |
||
| 12 | */ |
||
| 13 | protected function createController($module, $filename) |
||
| 14 | { |
||
| 15 | $this->info('Creating a new Controller'); |
||
|
|
|||
| 16 | $this->info('Creating ' . $module . ':' . $filename . ' Controller'); |
||
| 17 | $this->createControllersFolder($module); |
||
| 18 | if (!file_exists(base_path() . "/app/Modules/" . $module . "/Controllers/" . $filename . ".php")) { |
||
| 19 | file_put_contents( |
||
| 20 | base_path() . "/app/Modules/" . $module . "/Controllers/" . $filename . ".php", |
||
| 21 | $this->compileControllerStub($module, $filename) |
||
| 22 | ); |
||
| 23 | (file_exists(base_path() . "/app/Modules/" . $module . "/Controllers/" . $filename . ".php") ? $this->info('Done'):$this->error('An error occurred')); |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | $this->error('Controller already exists'); |
||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param $module |
||
| 32 | */ |
||
| 33 | protected function createControllersFolder($module) |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param $moduleName |
||
| 40 | * @param $className |
||
| 41 | * @return mixed |
||
| 42 | */ |
||
| 43 | protected function compileControllerStub($moduleName, $className) |
||
| 55 | ); |
||
| 56 | } |
||
| 58 | } |