Test Failed
Push — master ( 741545...e25e21 )
by Julien
11:23
created

ChannelChannelMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 145
Code Lines 101

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 101
c 0
b 0
f 0
dl 0
loc 145
ccs 0
cts 38
cp 0
rs 8
cc 1
nc 1
nop 0
crap 2

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
use Phalcon\Db\Column;
4
use Phalcon\Db\Index;
5
use Phalcon\Db\Reference;
6
use Phalcon\Migrations\Mvc\Model\Migration;
7
8
/**
9
 * Class ChannelChannelMigration_100
10
 */
11
class ChannelChannelMigration_100 extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Coding Style introduced by
Class name "ChannelChannelMigration_100" is not in PascalCase format

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
12
{
13
    /**
14
     * Define the table structure
15
     *
16
     * @return void
17
     */
18
    public function morph()
19
    {
20
        $this->morphTable('channel_channel', [
21
                'columns' => [
22
                    new Column(
23
                        'id',
24
                        [
25
                            'type' => Column::TYPE_INTEGER,
26
                            'unsigned' => true,
27
                            'notNull' => true,
28
                            'autoIncrement' => true,
29
                            'size' => 10,
30
                            'first' => true
31
                        ]
32
                    ),
33
                    new Column(
34
                        'left_channel_id',
35
                        [
36
                            'type' => Column::TYPE_INTEGER,
37
                            'unsigned' => true,
38
                            'notNull' => true,
39
                            'size' => 10,
40
                            'after' => 'id'
41
                        ]
42
                    ),
43
                    new Column(
44
                        'right_channel_id',
45
                        [
46
                            'type' => Column::TYPE_INTEGER,
47
                            'unsigned' => true,
48
                            'notNull' => true,
49
                            'size' => 10,
50
                            'after' => 'left_channel_id'
51
                        ]
52
                    ),
53
                    new Column(
54
                        'name',
55
                        [
56
                            'type' => Column::TYPE_VARCHAR,
57
                            'notNull' => true,
58
                            'size' => 191,
59
                            'after' => 'right_channel_id'
60
                        ]
61
                    ),
62
                    new Column(
63
                        'slug',
64
                        [
65
                            'type' => Column::TYPE_VARCHAR,
66
                            'notNull' => true,
67
                            'size' => 191,
68
                            'after' => 'name'
69
                        ]
70
                    ),
71
                    new Column(
72
                        'created_at',
73
                        [
74
                            'type' => Column::TYPE_DATETIME,
75
                            'default' => "current_timestamp()",
76
                            'notNull' => true,
77
                            'after' => 'slug'
78
                        ]
79
                    ),
80
                    new Column(
81
                        'updated_at',
82
                        [
83
                            'type' => Column::TYPE_DATETIME,
84
                            'notNull' => false,
85
                            'after' => 'created_at'
86
                        ]
87
                    ),
88
                    new Column(
89
                        'deleted_at',
90
                        [
91
                            'type' => Column::TYPE_DATETIME,
92
                            'notNull' => false,
93
                            'after' => 'updated_at'
94
                        ]
95
                    ),
96
                    new Column(
97
                        'deprecated_at',
98
                        [
99
                            'type' => Column::TYPE_DATETIME,
100
                            'notNull' => false,
101
                            'after' => 'deleted_at'
102
                        ]
103
                    ),
104
                    new Column(
105
                        'deprecated',
106
                        [
107
                            'type' => Column::TYPE_TINYINTEGER,
108
                            'default' => "0",
109
                            'unsigned' => true,
110
                            'notNull' => true,
111
                            'size' => 1,
112
                            'after' => 'deprecated_at'
113
                        ]
114
                    ),
115
                    new Column(
116
                        'deleted',
117
                        [
118
                            'type' => Column::TYPE_TINYINTEGER,
119
                            'default' => "0",
120
                            'unsigned' => true,
121
                            'notNull' => true,
122
                            'size' => 1,
123
                            'after' => 'deprecated'
124
                        ]
125
                    )
126
                ],
127
                'indexes' => [
128
                    new Index('PRIMARY', ['id'], 'PRIMARY'),
129
                    new Index('id_UNIQUE', ['id'], 'UNIQUE'),
130
                    new Index('channel_channel_id_unique', ['left_channel_id', 'right_channel_id', 'slug'], 'UNIQUE'),
131
                    new Index('right_channel_id_idx', ['right_channel_id'], ''),
132
                    new Index('left_channel_id_idx', ['left_channel_id'], '')
133
                ],
134
                'references' => [
135
                    new Reference(
136
                        'left_channel_id_fk',
137
                        [
138
                            'referencedTable' => 'channel',
139
                            'referencedSchema' => 'zemit',
140
                            'columns' => ['left_channel_id'],
141
                            'referencedColumns' => ['id'],
142
                            'onUpdate' => 'CASCADE',
143
                            'onDelete' => 'CASCADE'
144
                        ]
145
                    ),
146
                    new Reference(
147
                        'right_channel_id_fk',
148
                        [
149
                            'referencedTable' => 'channel',
150
                            'referencedSchema' => 'zemit',
151
                            'columns' => ['right_channel_id'],
152
                            'referencedColumns' => ['id'],
153
                            'onUpdate' => 'CASCADE',
154
                            'onDelete' => 'CASCADE'
155
                        ]
156
                    )
157
                ],
158
                'options' => [
159
                    'table_type' => 'BASE TABLE',
160
                    'auto_increment' => '',
161
                    'engine' => 'InnoDB',
162
                    'table_collation' => 'utf8mb4_general_ci'
163
                ],
164
            ]
165
        );
166
    }
167
168
    /**
169
     * Run the migrations
170
     *
171
     * @return void
172
     */
173
    public function up()
174
    {
175
176
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
177
178
    /**
179
     * Reverse the migrations
180
     *
181
     * @return void
182
     */
183
    public function down()
184
    {
185
186
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
187
188
}
189