Completed
Push — master ( 53b1ff...145864 )
by Dmitry
07:02 queued 02:50
created

Clear   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 93.33%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 27
ccs 14
cts 15
cp 0.9333
rs 10
c 1
b 1
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 24 6
1
<?php
2
3
namespace Basis\Job\Tarantool;
4
5
use Basis\Job;
6
use Tarantool\Client\Client;
7
use Tarantool\Client\Schema\Index;
8
use Basis\Filesystem;
9
10
class Clear extends Job
11
{
12 6
    public function run(Client $client, Filesystem $fs)
13
    {
14 6
        $space = $client->getSpace('_vspace');
15 6
        $response = $space->select([], Index::SPACE_NAME);
16 6
        $data = $response->getData();
17 6
        foreach ($data as $row) {
18 6
            if ($row[1] == 0) {
19
                // user space
20 6
                $client->evaluate('box.space.'.$row[2].':drop{}');
21
            }
22
        }
23
24 6
        $schema = $client->getSpace('_schema')->select([], 0)->getData();
25 6
        foreach ($schema as $tuple) {
26 6
            if (strpos($tuple[0], 'mapper-once') === 0) {
27 6
                $client->getSpace('_schema')->delete([$tuple[0]]);
28
            }
29
        }
30
31 6
        $filename = $fs->getPath('.cache/mapper-meta.php');
32 6
        if (file_exists($filename)) {
33
            unlink($filename);
34
        }
35 6
    }
36
}
37