Completed
Push — master ( 2761e7...346e09 )
by Dmitry
05:23
created

Migrate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 41.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 23
ccs 5
cts 12
cp 0.4167
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 20 3
1
<?php
2
3
namespace Basis\Jobs\Tarantool;
4
5
use Basis\Filesystem;
6
use Tarantool\Mapper\Bootstrap;
7
use Tarantool\Mapper\Mapper;
8
use Tarantool\Mapper\Plugins\Annotation;
9
10
class Migrate
11
{
12 1
    public function run(Mapper $mapper, Bootstrap $bootstrap, Filesystem $fs)
13
    {
14 1
        $mapper->getPlugin(Annotation::class)->migrate();
15
16 1
        foreach($fs->listFiles('resources/migrations') as $path) {
17
18
            list($ym, $filename) = explode('/', $path);
19
            $namespace = date_create_from_format('Ym', $ym)->format('FY');
20
21
            list($date, $time, $name) = explode('_', substr($filename, 0, -4));
22
            $class = $namespace.'\\'.$name;
23
24
            if(!class_exists($class, false)) {
25
                include $fs->getPath('resources/migrations/'.$path);
26
            }
27
            $bootstrap->register($class);
28
        }
29
30 1
        $bootstrap->migrate();
31 1
    }
32
}
33