Conditions | 3 |
Paths | 3 |
Total Lines | 58 |
Code Lines | 46 |
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 |
||
19 | public function up(Schema $schema): void |
||
20 | { |
||
21 | // Disable foreign key checks to prevent issues during migration |
||
22 | $this->addSql('SET FOREIGN_KEY_CHECKS = 0;'); |
||
23 | |||
24 | // Drop tables if they exist |
||
25 | $tablesToDrop = [ |
||
26 | 'page__snapshot', |
||
27 | 'class_item', |
||
28 | 'classification__collection', |
||
29 | 'c_userinfo_def', |
||
30 | 'class_user', |
||
31 | 'faq_question', |
||
32 | 'timeline__component', |
||
33 | 'page__page', |
||
34 | 'c_online_connected', |
||
35 | 'c_permission_task', |
||
36 | 'page__bloc', |
||
37 | 'c_online_link', |
||
38 | 'c_permission_user', |
||
39 | 'c_role_user', |
||
40 | 'c_role', |
||
41 | 'page__site', |
||
42 | 'shared_survey', |
||
43 | 'media__gallery', |
||
44 | 'faq_category', |
||
45 | 'classification__context', |
||
46 | 'timeline__timeline', |
||
47 | 'classification__category', |
||
48 | 'faq_question_translation', |
||
49 | 'c_userinfo_content', |
||
50 | 'contact_category', |
||
51 | 'classification__tag', |
||
52 | 'faq_category_translation', |
||
53 | 'timeline__action_component', |
||
54 | 'media__media', |
||
55 | 'c_role_permissions', |
||
56 | 'shared_survey_question_option', |
||
57 | 'shared_survey_question', |
||
58 | 'timeline__action', |
||
59 | 'contact_category_translation', |
||
60 | 'media__gallery_media', |
||
61 | 'c_item_property', |
||
62 | 'c_survey_group', |
||
63 | 'c_permission_group', |
||
64 | 'c_role_group', |
||
65 | 'track_e_open', |
||
66 | ]; |
||
67 | |||
68 | foreach ($tablesToDrop as $table) { |
||
69 | // Check if the table exists before attempting to drop it |
||
70 | if ($schema->hasTable($table)) { |
||
71 | $this->addSql("DROP TABLE $table;"); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | // Re-enable foreign key checks |
||
76 | $this->addSql('SET FOREIGN_KEY_CHECKS = 1;'); |
||
77 | } |
||
81 |