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

TemplateMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 130
Code Lines 87

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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