| Conditions | 1 |
| Paths | 1 |
| Total Lines | 84 |
| 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 |
||
| 10 | public function up () |
||
| 11 | { |
||
| 12 | Schema::table(config('phptelegrambot.database.prefix', '') . 'telegram_update', static function (Blueprint $table) { |
||
| 13 | $table->bigInteger('channel_post_id')->after('edited_message_id')->unsigned()->nullable()->comment('New incoming channel post of any kind - text, photo, sticker, etc.'); |
||
| 14 | $table->bigInteger('edited_channel_post_id')->after('channel_post_id')->unsigned()->nullable()->comment('New version of a channel post that is known to the bot and was edited'); |
||
| 15 | $table->bigInteger('shipping_query_id')->after('callback_query_id')->unsigned()->nullable()->comment('New incoming shipping query. Only for invoices with flexible price'); |
||
| 16 | $table->bigInteger('pre_checkout_query_id')->after('shipping_query_id')->unsigned()->nullable()->comment('New incoming pre-checkout query. Contains full information about checkout'); |
||
| 17 | $table->bigInteger('poll_id')->after('pre_checkout_query_id')->unsigned()->nullable()->comment('New poll state. Bots receive only updates about polls, which are sent or stopped by the bot'); |
||
| 18 | $table->bigInteger('poll_answer_poll_id')->after('poll_id')->unsigned()->nullable()->comment('A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.'); |
||
| 19 | |||
| 20 | // Add new indexes |
||
| 21 | $table->dropIndex ('message_id'); |
||
| 22 | $table->index (['message_id'], message_id); |
||
| 23 | $table->index (['chat_id', 'message_id'], 'chat_message_id'); |
||
| 24 | $table->index (['channel_post_id'], 'channel_post_id'); |
||
| 25 | $table->index (['edited_channel_post_id'], 'edited_channel_post_id'); |
||
| 26 | $table->index (['shipping_query_id'], 'shipping_query_id'); |
||
| 27 | $table->index (['pre_checkout_query_id'], 'pre_checkout_query_id'); |
||
| 28 | $table->index (['poll_id'], 'poll_id'); |
||
| 29 | $table->index (['poll_answer_poll_id'], 'poll_answer_poll_id'); |
||
| 30 | $table->index (['chat_id', 'channel_post_id'], 'chat_id'); |
||
| 31 | |||
| 32 | // Foreign indexes |
||
| 33 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_5'); |
||
| 34 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_4'); |
||
| 35 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_3'); |
||
| 36 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_2'); |
||
| 37 | $table->dropForeign (config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_1'); |
||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | $table->foreign ( |
||
| 46 | ['chat_id', 'message_id'], |
||
| 47 | config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_1' |
||
| 48 | ) |
||
| 49 | ->references (['chat_id', 'id'])->on (config('phptelegrambot.database.prefix', '') . 'message') |
||
| 50 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 51 | |||
| 52 | $table->foreign ('edited_message_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_2') |
||
| 53 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'edited_message') |
||
| 54 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 55 | |||
| 56 | $table->foreign (['chat_id', 'channel_post_id'], config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_3') |
||
| 57 | ->references (['chat_id', 'id'])->on (config('phptelegrambot.database.prefix', '') . 'message') |
||
| 58 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 59 | |||
| 60 | $table->foreign ('edited_channel_post_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_4') |
||
| 61 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'edited_message') |
||
| 62 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 63 | |||
| 64 | $table->foreign ('inline_query_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_5') |
||
| 65 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'inline_query') |
||
| 66 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 67 | |||
| 68 | $table->foreign ('chosen_inline_result_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_6') |
||
| 69 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'chosen_inline_result') |
||
| 70 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 71 | |||
| 72 | $table->foreign ('callback_query_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_7') |
||
| 73 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'callback_query') |
||
| 74 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 75 | |||
| 76 | $table->foreign ('shipping_query_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_8') |
||
| 77 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'shipping_query') |
||
| 78 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 79 | |||
| 80 | $table->foreign ('pre_checkout_query_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_9') |
||
| 81 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'pre_checkout_query') |
||
| 82 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 83 | |||
| 84 | $table->foreign ('poll_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_10') |
||
| 85 | ->references ('id')->on (config('phptelegrambot.database.prefix', '') . 'poll') |
||
| 86 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 87 | |||
| 88 | $table->foreign ('poll_answer_poll_id', config('phptelegrambot.database.prefix', '') . 'telegram_update_ibfk_11') |
||
| 89 | ->references ('poll_id')->on (config('phptelegrambot.database.prefix', '') . 'poll_answer') |
||
| 90 | ->onUpdate('RESTRICT')->onDelete('RESTRICT'); |
||
| 91 | |||
| 92 | }); |
||
| 93 | } |
||
| 94 | |||
| 156 |