Completed
Push — master ( e04029...518266 )
by Dmitry
03:33
created

Clear::run()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 17
cp 0
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 11
nc 9
nop 1
crap 30
1
<?php
2
3
namespace Basis\Job\Tarantool;
4
5
use Tarantool\Client\Client;
6
use Tarantool\Client\Schema\Index;
7
8
class Clear
9
{
10
    public function run(Client $client)
11
    {
12
        $space = $client->getSpace('_vspace');
13
        $response = $space->select([], Index::SPACE_NAME);
14
        $data = $response->getData();
15
        foreach ($data as $row) {
16
            if ($row[1] == 0) {
17
                // user space
18
                $client->evaluate('box.space.'.$row[2].':drop{}');
19
            }
20
        }
21
22
        $schema = $client->getSpace('_schema')->select([], 0)->getData();
23
        foreach ($schema as $tuple) {
24
            if (strpos($tuple[0], 'onceMigration\\') === 0) {
25
                $client->getSpace('_schema')->delete([$tuple[0]]);
26
            }
27
        }
28
    }
29
}
30