Passed
Pull Request — master (#3)
by
unknown
15:40
created

m180508_092223_create_pages_table   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 65
loc 65
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 34 1
A safeDown() 0 18 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
use Itstructure\AdminModule\components\MultilanguageMigration;
4
5
/**
6
 * Handles the creation of table `pages`.
7
 */
8
class m180508_092223_create_pages_table extends MultilanguageMigration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function safeUp()
14
    {
15
        $this->createMultiLanguageTable('pages',
16
            [
17
                'title' => $this->string(128)->notNull(),
18
                'description' => $this->text(),
19
                'content' => $this->text(),
20
                'metaKeys' => $this->string(128),
21
                'metaDescription' => $this->string(),
22
            ],
23
            [
24
                'parentId' => $this->integer(),
25
                'active' => $this->tinyInteger()->notNull()->defaultValue(0),
26
                'icon' => $this->string(128),
27
                'alias' => $this->string(128),
28
            ]
29
        );
30
31
        $this->createIndex(
32
            'idx-pages-parentId',
33
            'pages',
34
            'parentId'
35
        );
36
37
        $this->createIndex(
38
            'idx-pages-active',
39
            'pages',
40
            'active'
41
        );
42
43
        $this->createIndex(
44
            'idx-pages-alias',
45
            'pages',
46
            'alias'
47
        );
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function safeDown()
54
    {
55
        $this->dropIndex(
56
            'idx-pages-parentId',
57
            'pages'
58
        );
59
60
        $this->dropIndex(
61
            'idx-pages-active',
62
            'pages'
63
        );
64
65
        $this->dropIndex(
66
            'idx-pages-alias',
67
            'pages'
68
        );
69
70
        $this->dropMultiLanguageTable('pages');
71
    }
72
}
73