| Conditions | 5 |
| Paths | 16 |
| Total Lines | 36 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 22 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 2 | public function run(Filesystem $filesystem, Framework $framework) |
|
| 16 | { |
||
| 17 | 2 | $time = time(); |
|
| 18 | 2 | $namespace = date('FY', $time); |
|
| 19 | 2 | $created_at = date('Y-m-d H:i:s', $time); |
|
| 20 | |||
| 21 | 2 | if (!is_array($this->name)) { |
|
| 22 | 2 | $this->name = explode(' ', $this->name); |
|
| 23 | } |
||
| 24 | |||
| 25 | 2 | $class = ''; |
|
| 26 | 2 | foreach ($this->name as $piece) { |
|
| 27 | 2 | $class .= ucfirst($piece); |
|
| 28 | } |
||
| 29 | |||
| 30 | 2 | $template = $framework->getPath('resources/templates/migration.php'); |
|
| 31 | |||
| 32 | 2 | ob_start(); |
|
| 33 | 2 | include($template); |
|
| 34 | 2 | $contents = ob_get_clean(); |
|
| 35 | |||
| 36 | 2 | $path = $filesystem->getPath('php/Migration'); |
|
| 37 | 2 | if (!is_dir($path)) { |
|
| 38 | 1 | mkdir($path); |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | $path = $filesystem->getPath('php/Migration/'.$namespace); |
|
| 42 | 2 | if (!is_dir($path)) { |
|
| 43 | 2 | mkdir($path); |
|
| 44 | } |
||
| 45 | |||
| 46 | 2 | $filename = 'php/Migration/'.$namespace.'/'.$class.'.php'; |
|
| 47 | 2 | file_put_contents($filename, $contents); |
|
| 48 | |||
| 49 | 2 | return compact('filename', 'namespace', 'class'); |
|
| 50 | } |
||
| 51 | } |
||
| 52 |