Completed
Push — master ( 762e93...98e9e2 )
by Dmitry
32:47 queued 02:55
created

Bootstrap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 12
Bugs 1 Features 3
Metric Value
wmc 2
c 12
b 1
f 3
lcom 0
cbo 4
dl 0
loc 41
ccs 0
cts 31
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B migrate() 0 38 2
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('sequence')) {
13
            return true;
14
        }
15
16
        $schema = $manager->getSchema();
17
18
        $schema->createSpace('sequence');
19
        $schema->createIndex('sequence', 'id', ['parts' => [1, 'NUM']]);
20
        $schema->createIndex('sequence', 'space', ['parts' => [2, 'NUM']]);
21
22
        $schema->createSpace('property');
23
        $schema->createIndex('property', 'id', ['parts' => [1, 'NUM']]);
24
        $schema->createIndex('property', 'space', ['parts' => [2, 'NUM'], 'unique' => false]);
25
        $schema->createIndex('property', 'index_space', ['parts' => [3, 'NUM', 2, 'NUM']]);
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