Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
13 | public function safeUp() |
||
14 | { |
||
15 | $this->createTable('{{%confirmation_request}}', [ |
||
16 | |||
17 | 'id' => $this->primaryKey()->unsigned()->notNull(), |
||
18 | 'model' => $this->string(255), |
||
19 | 'object_id' => $this->integer(11)->unsigned(), |
||
20 | 'object' => $this->text(), |
||
21 | 'release_token' => $this->string(255), |
||
22 | 'created_at' => $this->integer(11), |
||
23 | 'updated_at' => $this->integer(11), |
||
24 | 'values' => $this->text(), |
||
25 | 'created_by' => $this->integer(11)->unsigned(), |
||
26 | 'updated_by' => $this->integer(11)->unsigned(), |
||
27 | |||
28 | ]); |
||
29 | |||
30 | // creates index for column `created_by` |
||
31 | $this->createIndex( |
||
32 | 'confirmation_request_ibfk_2', |
||
33 | '{{%confirmation_request}}', |
||
34 | 'created_by' |
||
35 | ); |
||
36 | |||
37 | // add foreign key for table `user` |
||
38 | $this->addForeignKey( |
||
39 | 'confirmation_request_ibfk_2', |
||
40 | '{{%confirmation_request}}', |
||
41 | 'created_by', |
||
42 | '{{%user}}', |
||
43 | 'id', |
||
44 | 'CASCADE' |
||
45 | ); |
||
46 | |||
47 | // creates index for column `updated_by` |
||
48 | $this->createIndex( |
||
49 | 'confirmation_request_ibfk_3', |
||
50 | '{{%confirmation_request}}', |
||
51 | 'updated_by' |
||
52 | ); |
||
53 | |||
54 | // add foreign key for table `user` |
||
55 | $this->addForeignKey( |
||
56 | 'confirmation_request_ibfk_3', |
||
57 | '{{%confirmation_request}}', |
||
58 | 'updated_by', |
||
59 | '{{%user}}', |
||
60 | 'id', |
||
61 | 'CASCADE' |
||
62 | ); |
||
63 | } |
||
64 | |||
97 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.