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