| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 3 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 116 | public function getDownSQL() |
||
| 117 | { |
||
| 118 | return array ( |
||
| 119 | 'keeko' => ' |
||
| 120 | # This is a fix for InnoDB in MySQL >= 4.1.x |
||
| 121 | # It "suspends judgement" for fkey relationships until are tables are set. |
||
| 122 | SET FOREIGN_KEY_CHECKS = 0; |
||
| 123 | |||
| 124 | ALTER TABLE `kk_application_uri` DROP FOREIGN KEY `application_uri_fk_application`; |
||
| 125 | |||
| 126 | ALTER TABLE `kk_application_uri` DROP FOREIGN KEY `application_uri_fk_localization`; |
||
| 127 | |||
| 128 | ALTER TABLE `kk_application_uri` ADD CONSTRAINT `application_uri_fk_application` |
||
| 129 | FOREIGN KEY (`application_id`) |
||
| 130 | REFERENCES `kk_application` (`id`); |
||
| 131 | |||
| 132 | ALTER TABLE `kk_application_uri` ADD CONSTRAINT `application_uri_fk_localization` |
||
| 133 | FOREIGN KEY (`localization_id`) |
||
| 134 | REFERENCES `kk_localization` (`id`); |
||
| 135 | |||
| 136 | ALTER TABLE `kk_group_action` DROP FOREIGN KEY `group_action_fk_action`; |
||
| 137 | |||
| 138 | ALTER TABLE `kk_group_action` DROP FOREIGN KEY `group_action_fk_group`; |
||
| 139 | |||
| 140 | ALTER TABLE `kk_group_action` ADD CONSTRAINT `group_action_fk_action` |
||
| 141 | FOREIGN KEY (`action_id`) |
||
| 142 | REFERENCES `kk_action` (`id`); |
||
| 143 | |||
| 144 | ALTER TABLE `kk_group_action` ADD CONSTRAINT `group_action_fk_group` |
||
| 145 | FOREIGN KEY (`group_id`) |
||
| 146 | REFERENCES `kk_group` (`id`); |
||
| 147 | |||
| 148 | ALTER TABLE `kk_localization_variant` DROP FOREIGN KEY `localization_variant_fk_localization`; |
||
| 149 | |||
| 150 | ALTER TABLE `kk_localization_variant` DROP FOREIGN KEY `localization_variant_fk_variant`; |
||
| 151 | |||
| 152 | ALTER TABLE `kk_localization_variant` ADD CONSTRAINT `localization_variant_fk_localization` |
||
| 153 | FOREIGN KEY (`localization_id`) |
||
| 154 | REFERENCES `kk_localization` (`id`); |
||
| 155 | |||
| 156 | ALTER TABLE `kk_localization_variant` ADD CONSTRAINT `localization_variant_fk_variant` |
||
| 157 | FOREIGN KEY (`variant_id`) |
||
| 158 | REFERENCES `kk_language_variant` (`id`); |
||
| 159 | |||
| 160 | ALTER TABLE `kk_user_group` DROP FOREIGN KEY `user_group_fk_group`; |
||
| 161 | |||
| 162 | ALTER TABLE `kk_user_group` DROP FOREIGN KEY `user_group_fk_user`; |
||
| 163 | |||
| 164 | ALTER TABLE `kk_user_group` ADD CONSTRAINT `user_group_fk_group` |
||
| 165 | FOREIGN KEY (`group_id`) |
||
| 166 | REFERENCES `kk_group` (`id`); |
||
| 167 | |||
| 168 | ALTER TABLE `kk_user_group` ADD CONSTRAINT `user_group_fk_user` |
||
| 169 | FOREIGN KEY (`user_id`) |
||
| 170 | REFERENCES `kk_user` (`id`); |
||
| 171 | |||
| 172 | CREATE TABLE `kk_auth` |
||
| 173 | ( |
||
| 174 | `token` VARCHAR(32) NOT NULL, |
||
| 175 | `user_id` INTEGER(10) NOT NULL, |
||
| 176 | `created_at` DATETIME, |
||
| 177 | `updated_at` DATETIME, |
||
| 178 | PRIMARY KEY (`token`), |
||
| 179 | INDEX `auth_fi_user` (`user_id`), |
||
| 180 | CONSTRAINT `auth_fk_user` |
||
| 181 | FOREIGN KEY (`user_id`) |
||
| 182 | REFERENCES `kk_user` (`id`) |
||
| 183 | ) ENGINE=InnoDB; |
||
| 184 | |||
| 185 | # This restores the fkey checks, after having unset them earlier |
||
| 186 | SET FOREIGN_KEY_CHECKS = 1; |
||
| 187 | ', |
||
| 188 | ); |
||
| 189 | } |
||
| 190 | |||
| 191 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.