GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a54314...1f466c )
by Pavel
04:30
created

TestMigration::up()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 55
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 45
CRAP Score 5
Metric Value
dl 0
loc 55
ccs 45
cts 45
cp 1
rs 8.7753
cc 5
eloc 40
nc 16
nop 0
crap 5

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * @link https://github.com/paulzi/yii2-materialized-path
4
 * @copyright Copyright (c) 2015 PaulZi <[email protected]>
5
 * @license MIT (https://github.com/paulzi/yii2-materialized-path/blob/master/LICENSE)
6
 */
7
8
namespace paulzi\materializedPath\tests\migrations;
9
10
use yii\db\Schema;
11
use yii\db\Migration;
12
13
/**
14
 * @author PaulZi <[email protected]>
15
 */
16
class TestMigration extends Migration
17
{
18 201
    public function up()
19
    {
20 201
        ob_start();
21 201
        $tableOptions = null;
22 201
        if ($this->db->driverName === 'mysql') {
23
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
24 67
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
25 67
        }
26
27
        // tree
28 201
        if ($this->db->getTableSchema('{{%tree}}', true) !== null) {
29 197
            $this->dropTable('{{%tree}}');
30 197
        }
31 201
        $this->createTable('{{%tree}}', [
32 201
            'id'    => Schema::TYPE_PK,
33 201
            'path'  => Schema::TYPE_STRING . ' NULL',
34 201
            'depth' => Schema::TYPE_INTEGER . ' NOT NULL',
35 201
            'sort'  => Schema::TYPE_INTEGER . ' NOT NULL',
36 201
            'slug'  => Schema::TYPE_STRING . ' NOT NULL',
37 201
        ], $tableOptions);
38 201
        $this->createIndex('path', '{{%tree}}', ['path']);
39
40
        // attribute mode tree
41 201
        if ($this->db->getTableSchema('{{%attribute_mode_tree}}', true) !== null) {
42 197
            $this->dropTable('{{%attribute_mode_tree}}');
43 197
        }
44 201
        $this->createTable('{{%attribute_mode_tree}}', [
45 201
            'id'    => Schema::TYPE_PK,
46 201
            'path'  => Schema::TYPE_STRING . ' NULL',
47 201
            'depth' => Schema::TYPE_INTEGER . ' NOT NULL',
48 201
            'sort'  => Schema::TYPE_INTEGER . ' NOT NULL',
49 201
            'slug'  => Schema::TYPE_STRING . ' NOT NULL',
50 201
        ], $tableOptions);
51 201
        $this->createIndex('path2', '{{%attribute_mode_tree}}', ['path']);
52
53
        // multiple tree
54 201
        if ($this->db->getTableSchema('{{%multiple_tree}}', true) !== null) {
55 197
            $this->dropTable('{{%multiple_tree}}');
56 197
        }
57 201
        $this->createTable('{{%multiple_tree}}', [
58 201
            'id'    => Schema::TYPE_PK,
59 201
            'tree'  => Schema::TYPE_INTEGER . ' NULL',
60 201
            'path'  => Schema::TYPE_STRING . ' NULL',
61 201
            'depth' => Schema::TYPE_INTEGER . ' NOT NULL',
62 201
            'sort'  => Schema::TYPE_INTEGER . ' NOT NULL',
63 201
            'slug'  => Schema::TYPE_STRING . ' NOT NULL',
64 201
        ], $tableOptions);
65 201
        $this->createIndex('path3', '{{%multiple_tree}}', ['tree', 'path']);
66
67
        // update cache (sqlite bug)
68 201
        $this->db->getSchema()->getTableSchema('{{%tree}}', true);
69 201
        $this->db->getSchema()->getTableSchema('{{%attribute_mode_tree}}', true);
70 201
        $this->db->getSchema()->getTableSchema('{{%multiple_tree}}', true);
71 201
        ob_end_clean();
72 201
    }
73
}
74