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

ProjectMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 125
Code Lines 85

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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