Completed
Push — master ( 229d8c...e7f8de )
by Dmitry
02:48
created

Bootstrap::migrate()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 38
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.9954

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 38
ccs 6
cts 29
cp 0.2069
rs 8.8571
c 1
b 0
f 1
cc 2
eloc 28
nc 2
nop 1
crap 3.9954
1
<?php
2
3
namespace Tarantool\Mapper\Migrations;
4
5
use Tarantool\Mapper\Contracts;
6
7
class Bootstrap implements Contracts\Migration
8
{
9 64
    public function migrate(Contracts\Manager $manager)
10
    {
11 64
        $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 64
        if ($manager->getSchema()->hasSpace('sequence')) {
13
            return true;
14
        }
15
16 64
        $schema = $manager->getSchema();
17
18 64
        $schema->createSpace('sequence');
19 64
        $schema->createIndex('sequence', 'id', ['parts' => [1, 'UNSIGNED']]);
20
        $schema->createIndex('sequence', 'space', ['parts' => [2, 'UNSIGNED']]);
21
22
        $schema->createSpace('property');
23
        $schema->createIndex('property', 'id', ['parts' => [1, 'UNSIGNED']]);
24
        $schema->createIndex('property', 'space', ['parts' => [2, 'UNSIGNED'], 'unique' => false]);
25
        $schema->createIndex('property', 'index_space', ['parts' => [3, 'UNSIGNED', 2, 'UNSIGNED']]);
26
        $schema->createIndex('property', 'type', ['parts' => [5, 'STR'], 'unique' => false]);
27
28
        $client = $manager->getClient();
29
30
        $sequenceSpaceId = $schema->getSpaceId('sequence');
31
        $propertySpaceId = $schema->getSpaceId('property');
32
33
        $property = $client->getSpace('property');
34
        $property->insert([1, $sequenceSpaceId, 0, 'id', 'integer']);
35
        $property->insert([2, $sequenceSpaceId, 1, 'space', 'integer']);
36
        $property->insert([3, $sequenceSpaceId, 2, 'value', 'integer']);
37
        $property->insert([4, $propertySpaceId, 0, 'id', 'integer']);
38
        $property->insert([5, $propertySpaceId, 1, 'space', 'integer']);
39
        $property->insert([6, $propertySpaceId, 2, 'index', 'integer']);
40
        $property->insert([7, $propertySpaceId, 3, 'name', 'string']);
41
        $property->insert([8, $propertySpaceId, 4, 'type', 'string']);
42
43
        $sequence = $client->getSpace('sequence');
44
        $sequence->insert([1, $sequenceSpaceId, 2]);
45
        $sequence->insert([2, $propertySpaceId, 8]);
46
    }
47
}
48