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

Bootstrap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 20.69%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 41
ccs 6
cts 29
cp 0.2069
rs 10
c 1
b 0
f 1

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 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