Completed
Push — master ( 2705ab...006cbd )
by Dmitry
04:32
created

Clear   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 19 5
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
9
class Clear extends Job
10
{
11 5
    public function run(Client $client)
12
    {
13 5
        $space = $client->getSpace('_vspace');
14 5
        $response = $space->select([], Index::SPACE_NAME);
15 5
        $data = $response->getData();
16 5
        foreach ($data as $row) {
17 5
            if ($row[1] == 0) {
18
                // user space
19 5
                $client->evaluate('box.space.'.$row[2].':drop{}');
20
            }
21
        }
22
23 5
        $schema = $client->getSpace('_schema')->select([], 0)->getData();
24 5
        foreach ($schema as $tuple) {
25 5
            if (strpos($tuple[0], 'mapper-once') === 0) {
26 5
                $client->getSpace('_schema')->delete([$tuple[0]]);
27
            }
28
        }
29 5
    }
30
}
31