Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
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 |
||
95 | public function down () |
||
96 | { |
||
97 | Schema::table(config('phptelegrambot.database.prefix', '') . 'telegram_update', static function (Blueprint $table) { |
||
98 | $table->dropColumn ('channel_post_id'); |
||
99 | $table->dropColumn ('edited_channel_post_id'); |
||
100 | $table->dropColumn ('shipping_query_id'); |
||
101 | $table->dropColumn ('pre_checkout_query_id'); |
||
102 | $table->dropColumn ('poll_id'); |
||
103 | $table->dropColumn ('poll_answer_poll_id'); |
||
104 | |||
105 | // Rollback old index |
||
106 | $table->dropIndex ('message_id'); |
||
107 | $table->index (['chat_id', 'message_id'], 'message_id'); |
||
108 | |||
109 | // Drop new simple keys |
||
110 | $table->dropIndex ('chat_message_id'); |
||
111 | $table->dropIndex ('channel_post_id'); |
||
112 | $table->dropIndex ('edited_channel_post_id'); |
||
113 | $table->dropIndex ('shipping_query_id'); |
||
114 | $table->dropIndex ('pre_checkout_query_id'); |
||
115 | $table->dropIndex ('poll_id'); |
||
116 | $table->dropIndex ('poll_answer_poll_id'); |
||
117 | $table->dropIndex ('chat_id'); |
||
118 | |||
119 | // Drop new foreign keys |
||
120 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_6'); |
||
121 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_7'); |
||
122 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_8'); |
||
123 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_9'); |
||
124 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_10'); |
||
125 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_11'); |
||
126 | |||
127 | // Restore old foreign keys |
||
128 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_1'); |
||
129 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_2'); |
||
130 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_3'); |
||
131 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_4'); |
||
132 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_5'); |
||
133 | |||
134 | $table->foreign ('chat_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_1') |
||
135 | ->references ('chat_id')->on (config('phptelegrambot.database.prefix', '') . 'message') |
||
136 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
137 | |||
138 | $table->foreign ('inline_query_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_2') |
||
139 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'inline_query') |
||
140 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
141 | |||
142 | $table->foreign ('chosen_inline_result_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_3') |
||
143 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'chosen_inline_result') |
||
144 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
145 | |||
146 | $table->foreign ('callback_query_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_4') |
||
147 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'callback_query') |
||
148 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
149 | |||
150 | $table->foreign ('edited_message_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_5') |
||
151 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'edited_message') |
||
152 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
153 | }); |
||
154 | } |
||
155 | } |
||
156 |