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

ValidationMigration_100::morph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 115
Code Lines 78

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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