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

FieldMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 106
Code Lines 72

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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