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

LogMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 141
Code Lines 98

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 98
c 1
b 0
f 0
dl 0
loc 141
ccs 0
cts 39
cp 0
rs 8.0436
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 LogMigration_100
10
 */
11
class LogMigration_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 "LogMigration_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('log', [
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
                        'log_id',
35
                        [
36
                            'type' => Column::TYPE_INTEGER,
37
                            'unsigned' => true,
38
                            'notNull' => false,
39
                            'size' => 10,
40
                            'after' => 'id'
41
                        ]
42
                    ),
43
                    new Column(
44
                        'table',
45
                        [
46
                            'type' => Column::TYPE_CHAR,
47
                            'notNull' => true,
48
                            'size' => 60,
49
                            'after' => 'log_id'
50
                        ]
51
                    ),
52
                    new Column(
53
                        'table_id',
54
                        [
55
                            'type' => Column::TYPE_INTEGER,
56
                            'unsigned' => true,
57
                            'notNull' => false,
58
                            'size' => 10,
59
                            'after' => 'table'
60
                        ]
61
                    ),
62
                    new Column(
63
                        'user_id',
64
                        [
65
                            'type' => Column::TYPE_INTEGER,
66
                            'unsigned' => true,
67
                            'notNull' => false,
68
                            'size' => 10,
69
                            'after' => 'table_id'
70
                        ]
71
                    ),
72
                    new Column(
73
                        'client_ip',
74
                        [
75
                            'type' => Column::TYPE_VARCHAR,
76
                            'notNull' => false,
77
                            'size' => 16,
78
                            'after' => 'user_id'
79
                        ]
80
                    ),
81
                    new Column(
82
                        'server_ip',
83
                        [
84
                            'type' => Column::TYPE_VARCHAR,
85
                            'notNull' => false,
86
                            'size' => 16,
87
                            'after' => 'client_ip'
88
                        ]
89
                    ),
90
                    new Column(
91
                        'before',
92
                        [
93
                            'type' => Column::TYPE_TEXT,
94
                            'notNull' => false,
95
                            'after' => 'server_ip'
96
                        ]
97
                    ),
98
                    new Column(
99
                        'after',
100
                        [
101
                            'type' => Column::TYPE_TEXT,
102
                            'notNull' => false,
103
                            'after' => 'before'
104
                        ]
105
                    ),
106
                    new Column(
107
                        'meta',
108
                        [
109
                            'type' => Column::TYPE_TEXT,
110
                            'notNull' => false,
111
                            'after' => 'after'
112
                        ]
113
                    ),
114
                    new Column(
115
                        'created_date',
116
                        [
117
                            'type' => Column::TYPE_DATETIME,
118
                            'notNull' => false,
119
                            'after' => 'meta'
120
                        ]
121
                    ),
122
                    new Column(
123
                        'updated_date',
124
                        [
125
                            'type' => Column::TYPE_DATETIME,
126
                            'notNull' => false,
127
                            'after' => 'created_date'
128
                        ]
129
                    ),
130
                    new Column(
131
                        'deleted',
132
                        [
133
                            'type' => Column::TYPE_INTEGER,
134
                            'default' => "0",
135
                            'unsigned' => true,
136
                            'notNull' => true,
137
                            'size' => 1,
138
                            'after' => 'updated_date'
139
                        ]
140
                    )
141
                ],
142
                'indexes' => [
143
                    new Index('PRIMARY', ['id'], 'PRIMARY'),
144
                    new Index('id_UNIQUE', ['id'], 'UNIQUE'),
145
                    new Index('id_index', ['id'], ''),
146
                    new Index('table_index', ['table'], ''),
147
                    new Index('table_id_index', ['table_id'], ''),
148
                    new Index('table_table_id_index', ['table', 'table_id'], ''),
149
                    new Index('deleted_index', ['deleted'], ''),
150
                    new Index('user_id_index', ['user_id'], ''),
151
                    new Index('client_ip_index', ['client_ip'], ''),
152
                    new Index('server_ip_index', ['server_ip'], '')
153
                ],
154
                'options' => [
155
                    'table_type' => 'BASE TABLE',
156
                    'auto_increment' => '',
157
                    'engine' => 'InnoDB',
158
                    'table_collation' => 'utf8mb4_general_ci'
159
                ],
160
            ]
161
        );
162
    }
163
164
    /**
165
     * Run the migrations
166
     *
167
     * @return void
168
     */
169
    public function up()
170
    {
171
172
    }
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...
173
174
    /**
175
     * Reverse the migrations
176
     *
177
     * @return void
178
     */
179
    public function down()
180
    {
181
182
    }
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...
183
184
}
185