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