Completed
Push — master ( c3ecfe...45dd7f )
by Dmitry
02:45
created

Bootstrap::run()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 22
ccs 0
cts 20
cp 0
rs 8.6737
c 1
b 1
f 0
cc 5
eloc 14
nc 6
nop 1
crap 30
1
<?php
2
3
namespace Basis\Job\Module;
4
5
use Basis\Job;
6
use Exception;
7
use Basis\Filesystem;
8
9
class Bootstrap extends Job
10
{
11
    public function run(Filesystem $fs)
12
    {
13
        $result = [];
14
        $cache = $fs->getPath('.cache');
15
        if (is_dir($cache)) {
16
            foreach ($fs->listFiles('.cache') as $file) {
17
                unlink($fs->getPath('.cache/'.$file));
18
            }
19
            rmdir($cache);
20
        }
21
22
        $jobs = ['tarantool.migrate', 'tarantool.cache', 'module.defaults', 'module.register'];
23
        foreach ($jobs as $job) {
24
            try {
25
                $result[$job] = $this->dispatch($job);
26
            } catch (Exception $e) {
27
                $result[$job] = $e->getMessage();
28
            }
29
        }
30
31
        return $result;
32
    }
33
}
34