Conditions | 2 |
Paths | 2 |
Total Lines | 124 |
Code Lines | 78 |
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 |
||
28 | public function change() { |
||
29 | |||
30 | if ($this->hasTable("river")) { |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | $table = $this->table("river", [ |
||
35 | 'engine' => "InnoDB", |
||
36 | 'encoding' => "utf8mb4", |
||
37 | 'collation' => "utf8mb4_general_ci", |
||
38 | ]); |
||
39 | |||
40 | $table->addColumn('type', 'string', [ |
||
41 | 'null' => false, |
||
42 | 'limit' => 8, |
||
43 | ]); |
||
44 | |||
45 | $table->addColumn('subtype', 'string', [ |
||
46 | 'null' => false, |
||
47 | 'limit' => 32, |
||
48 | ]); |
||
49 | |||
50 | $table->addColumn('action_type', 'string', [ |
||
51 | 'null' => false, |
||
52 | 'limit' => 32, |
||
53 | ]); |
||
54 | |||
55 | $table->addColumn('access_id', 'integer', [ |
||
56 | 'null' => false, |
||
57 | 'limit' => MysqlAdapter::INT_REGULAR, |
||
58 | 'precision' => 10, |
||
59 | ]); |
||
60 | |||
61 | $table->addColumn('view', 'text', [ |
||
62 | 'null' => false, |
||
63 | 'limit' => 65535, |
||
64 | ]); |
||
65 | |||
66 | $table->addColumn('subject_guid', 'integer', [ |
||
67 | 'null' => false, |
||
68 | 'limit' => MysqlAdapter::INT_BIG, |
||
69 | 'precision' => 20, |
||
70 | 'signed' => false, |
||
71 | ]); |
||
72 | |||
73 | $table->addColumn('object_guid', 'integer', [ |
||
74 | 'null' => false, |
||
75 | 'limit' => MysqlAdapter::INT_BIG, |
||
76 | 'precision' => 20, |
||
77 | 'signed' => false, |
||
78 | ]); |
||
79 | |||
80 | $table->addColumn('target_guid', 'integer', [ |
||
81 | 'null' => false, |
||
82 | 'limit' => MysqlAdapter::INT_BIG, |
||
83 | 'precision' => 20, |
||
84 | 'signed' => false, |
||
85 | ]); |
||
86 | |||
87 | $table->addColumn('annotation_id', 'integer', [ |
||
88 | 'null' => false, |
||
89 | 'limit' => MysqlAdapter::INT_REGULAR, |
||
90 | 'precision' => 10, |
||
91 | ]); |
||
92 | |||
93 | $table->addColumn('posted', 'integer', [ |
||
94 | 'null' => false, |
||
95 | 'limit' => MysqlAdapter::INT_REGULAR, |
||
96 | 'precision' => 10, |
||
97 | ]); |
||
98 | |||
99 | $table->addColumn('enabled', 'enum', [ |
||
100 | 'null' => false, |
||
101 | 'default' => 'yes', |
||
102 | 'limit' => 3, |
||
103 | 'values' => [ |
||
104 | 'yes', |
||
105 | 'no' |
||
106 | ], |
||
107 | ]); |
||
108 | |||
109 | $table->addIndex(['type'], [ |
||
110 | 'name' => "type", |
||
111 | 'unique' => false, |
||
112 | ]); |
||
113 | |||
114 | $table->addIndex(['action_type'], [ |
||
115 | 'name' => "action_type", |
||
116 | 'unique' => false, |
||
117 | ]); |
||
118 | |||
119 | $table->addIndex(['access_id'], [ |
||
120 | 'name' => "access_id", |
||
121 | 'unique' => false, |
||
122 | ]); |
||
123 | |||
124 | $table->addIndex(['subject_guid'], [ |
||
125 | 'name' => "subject_guid", |
||
126 | 'unique' => false, |
||
127 | ]); |
||
128 | |||
129 | $table->addIndex(['object_guid'], [ |
||
130 | 'name' => "object_guid", |
||
131 | 'unique' => false, |
||
132 | ]); |
||
133 | |||
134 | $table->addIndex(['target_guid'], [ |
||
135 | 'name' => "target_guid", |
||
136 | 'unique' => false, |
||
137 | ]); |
||
138 | |||
139 | $table->addIndex(['annotation_id'], [ |
||
140 | 'name' => "annotation_id", |
||
141 | 'unique' => false, |
||
142 | ]); |
||
143 | |||
144 | $table->addIndex(['posted'], [ |
||
145 | 'name' => "posted", |
||
146 | 'unique' => false, |
||
147 | ]); |
||
148 | |||
149 | $table->save(); |
||
150 | |||
151 | } |
||
152 | } |
||
153 |