Completed
Push — master ( 5a6cbe...c8e6dd )
by Dmitry
05:03
created

Migrate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 41.67%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 19 3
1
<?php
2
3
namespace Basis\Job\Tarantool;
4
5
use Basis\Filesystem;
6
use Tarantool\Mapper\Bootstrap;
7
use Tarantool\Mapper\Mapper;
8
use Tarantool\Mapper\Plugin\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
            list($ym, $filename) = explode('/', $path);
18
            $namespace = date_create_from_format('Ym', $ym)->format('FY');
19
20
            list($date, $time, $name) = explode('_', substr($filename, 0, -4));
21
            $class = $namespace.'\\'.$name;
22
23
            if (!class_exists($class, false)) {
24
                include $fs->getPath('resources/migrations/'.$path);
25
            }
26
            $bootstrap->register($class);
27
        }
28
29 1
        $bootstrap->migrate();
30 1
    }
31
}
32