| Conditions | 7 |
| Paths | 24 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 7.049 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 42 | public function run(Mapper $mapper, Bootstrap $bootstrap, Filesystem $fs, Application $app) |
|
| 17 | { |
||
| 18 | 42 | $mapper->getPlugin(Annotation::class)->migrate(); |
|
| 19 | |||
| 20 | 42 | $migrations = []; |
|
| 21 | 42 | foreach ($fs->listClasses('Migration') as $class) { |
|
| 22 | 1 | $reflection = new ReflectionClass($class); |
|
| 23 | 1 | $created_at = $reflection->getDefaultProperties()['created_at']; |
|
| 24 | 1 | if (!array_key_exists($created_at, $migrations)) { |
|
| 25 | 1 | $migrations[$created_at] = []; |
|
| 26 | } |
||
| 27 | 1 | $migrations[$created_at][] = $class; |
|
| 28 | } |
||
| 29 | 42 | ksort($migrations); |
|
| 30 | |||
| 31 | 42 | foreach ($migrations as $collection) { |
|
| 32 | 1 | foreach ($collection as $class) { |
|
| 33 | 1 | if (method_exists($class, '__construct')) { |
|
| 34 | $class = $app->get($class); |
||
| 35 | } |
||
| 36 | 1 | $bootstrap->register($class); |
|
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | 42 | $bootstrap->migrate(); |
|
| 41 | |||
| 42 | 42 | $filename = $fs->getPath('.cache/mapper-meta.php'); |
|
| 43 | 42 | if (file_exists($filename)) { |
|
| 44 | $this->dispatch('tarantool.cache'); |
||
| 45 | } |
||
| 46 | 42 | } |
|
| 47 | } |
||
| 48 |