Conditions | 1 |
Paths | 1 |
Total Lines | 69 |
Code Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
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 |
||
16 | public function safeUp() |
||
17 | { |
||
18 | $this->createTable(Domain::tableName(), [ |
||
19 | 'fieldId' => $this->integer()->notNull(), |
||
20 | 'elementId' => $this->integer()->notNull(), |
||
21 | 'domain' => $this->string()->notNull(), |
||
22 | 'status' => $this->enum('status', ['enabled', 'pending', 'disabled'])->notNull()->defaultValue('enabled'), |
||
23 | 'sortOrder' => $this->smallInteger()->unsigned(), |
||
24 | 'siteId' => $this->integer()->notNull(), |
||
25 | 'dateCreated' => $this->dateTime()->notNull(), |
||
26 | 'dateUpdated' => $this->dateTime()->notNull(), |
||
27 | 'uid' => $this->uid(), |
||
28 | ]); |
||
29 | |||
30 | $this->addPrimaryKey( |
||
31 | null, |
||
32 | Domain::tableName(), |
||
33 | [ |
||
34 | 'fieldId', |
||
35 | 'elementId', |
||
36 | 'domain', |
||
37 | 'siteId' |
||
38 | ] |
||
39 | ); |
||
40 | |||
41 | $this->createIndex( |
||
42 | null, |
||
43 | Domain::tableName(), |
||
44 | 'domain', |
||
45 | false |
||
46 | ); |
||
47 | |||
48 | $this->createIndex( |
||
49 | null, |
||
50 | Domain::tableName(), |
||
51 | 'status', |
||
52 | false |
||
53 | ); |
||
54 | |||
55 | $this->addForeignKey( |
||
56 | null, |
||
57 | Domain::tableName(), |
||
58 | 'fieldId', |
||
59 | Field::tableName(), |
||
60 | 'id', |
||
61 | 'CASCADE', |
||
62 | null |
||
63 | ); |
||
64 | |||
65 | $this->addForeignKey( |
||
66 | null, |
||
67 | Domain::tableName(), |
||
68 | 'elementId', |
||
69 | Element::tableName(), |
||
70 | 'id', |
||
71 | 'CASCADE', |
||
72 | null |
||
73 | ); |
||
74 | |||
75 | $this->addForeignKey( |
||
76 | null, |
||
77 | Domain::tableName(), |
||
78 | 'siteId', |
||
79 | Site::tableName(), |
||
80 | 'id', |
||
81 | 'CASCADE', |
||
82 | 'CASCADE' |
||
83 | ); |
||
84 | } |
||
85 | |||
94 |