| Conditions | 5 |
| Paths | 16 |
| Total Lines | 35 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 21 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 15 | 1 | function run(Filesystem $filesystem, Framework $framework) |
|
|
|
|||
| 16 | {
|
||
| 17 | 1 | $time = time(); |
|
| 18 | 1 | $namespace = date('FY', $time);
|
|
| 19 | |||
| 20 | 1 | if(!is_array($this->name)) {
|
|
| 21 | 1 | $this->name = explode(' ', $this->name);
|
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | $class = ''; |
|
| 25 | 1 | foreach($this->name as $piece) {
|
|
| 26 | 1 | $class .= ucfirst($piece); |
|
| 27 | } |
||
| 28 | |||
| 29 | 1 | $template = $framework->getPath('resources/templates/migration.php');
|
|
| 30 | |||
| 31 | 1 | ob_start(); |
|
| 32 | 1 | include($template); |
|
| 33 | 1 | $contents = ob_get_clean(); |
|
| 34 | |||
| 35 | 1 | $path = $filesystem->getPath('resources/migrations');
|
|
| 36 | 1 | if(!is_dir($path)) {
|
|
| 37 | 1 | mkdir($path); |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | $path = $filesystem->getPath('resources/migrations/'.date('Ym', $time));
|
|
| 41 | 1 | if(!is_dir($path)) {
|
|
| 42 | 1 | mkdir($path); |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | $filename = $path.'/'.$class.'.php'; |
|
| 46 | 1 | file_put_contents($filename, $contents); |
|
| 47 | |||
| 48 | 1 | return compact('filename', 'namespace', 'class');
|
|
| 49 | } |
||
| 50 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.