Completed
Push — master ( addaf0...c57d80 )
by Dmitry
03:20
created

Bootstrap::migrate()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 32
ccs 0
cts 26
cp 0
rs 8.8571
cc 2
eloc 23
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Tarantool\Mapper\Migrations;
4
5
use Tarantool\Mapper\Contracts;
6
7
class Bootstrap implements Contracts\Migration
8
{
9
    public function migrate(Contracts\Manager $manager)
10
    {
11
        $client = $manager->getClient();
0 ignored issues
show
Unused Code introduced by
$client is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
12
        if ($manager->getSchema()->hasSpace('sequences')) {
13
            return true;
14
        }
15
16
        $schema = $manager->getSchema();
17
18
        $schema->createSpace('sequences');
19
        $schema->createIndex('sequences', 'id', ['parts' => [1, 'NUM']]);
20
        $schema->createIndex('sequences', 'name', ['parts' => [2, 'STR']]);
21
22
        $schema->createSpace('mapping');
23
        $schema->createIndex('mapping', 'id', ['parts' => [1, 'NUM']]);
24
        $schema->createIndex('mapping', 'space', ['parts' => [2, 'STR'], 'unique' => false]);
25
26
        $client = $manager->getClient();
27
28
        $mapping = $client->getSpace('mapping');
29
        $mapping->insert([1, 'sequences', 0, 'id']);
30
        $mapping->insert([2, 'sequences', 1, 'name']);
31
        $mapping->insert([3, 'sequences', 2, 'value']);
32
        $mapping->insert([4, 'mapping', 0, 'id']);
33
        $mapping->insert([5, 'mapping', 1, 'space']);
34
        $mapping->insert([6, 'mapping', 2, 'line']);
35
        $mapping->insert([7, 'mapping', 3, 'property']);
36
37
        $sequence = $client->getSpace('sequences');
38
        $sequence->insert([1, 'sequences', 2]);
39
        $sequence->insert([2, 'mapping', 7]);
40
    }
41
}
42