| Conditions | 4 |
| Paths | 6 |
| Total Lines | 124 |
| 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 |
||
| 132 | private function getPhpbbFixtures($table) |
||
| 133 | { |
||
| 134 | switch ($table) { |
||
| 135 | case 'c_posts': |
||
| 136 | $sql = " |
||
| 137 | CREATE TABLE IF NOT EXISTS `c_posts` ( |
||
| 138 | `post_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, |
||
| 139 | `topic_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 140 | `forum_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 141 | `poster_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 142 | `icon_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 143 | `poster_ip` varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 144 | `post_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 145 | `post_reported` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 146 | `enable_bbcode` tinyint(1) unsigned NOT NULL DEFAULT '1', |
||
| 147 | `enable_smilies` tinyint(1) unsigned NOT NULL DEFAULT '1', |
||
| 148 | `enable_magic_url` tinyint(1) unsigned NOT NULL DEFAULT '1', |
||
| 149 | `enable_sig` tinyint(1) unsigned NOT NULL DEFAULT '1', |
||
| 150 | `post_username` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 151 | `post_subject` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', |
||
| 152 | `post_text` mediumtext COLLATE utf8_bin NOT NULL, |
||
| 153 | `post_checksum` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 154 | `post_attachment` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 155 | `bbcode_bitfield` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 156 | `bbcode_uid` varchar(8) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 157 | `post_postcount` tinyint(1) unsigned NOT NULL DEFAULT '1', |
||
| 158 | `post_edit_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 159 | `post_edit_reason` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 160 | `post_edit_user` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 161 | `post_edit_count` smallint(4) unsigned NOT NULL DEFAULT '0', |
||
| 162 | `post_edit_locked` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 163 | `post_visibility` tinyint(3) NOT NULL DEFAULT '0', |
||
| 164 | `post_delete_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 165 | `post_delete_reason` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 166 | `post_delete_user` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 167 | PRIMARY KEY (`post_id`), |
||
| 168 | KEY `forum_id` (`forum_id`), |
||
| 169 | KEY `topic_id` (`topic_id`), |
||
| 170 | KEY `poster_ip` (`poster_ip`), |
||
| 171 | KEY `poster_id` (`poster_id`), |
||
| 172 | KEY `post_username` (`post_username`), |
||
| 173 | KEY `tid_post_time` (`topic_id`,`post_time`), |
||
| 174 | KEY `post_visibility` (`post_visibility`) |
||
| 175 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=6 ; |
||
| 176 | |||
| 177 | -- |
||
| 178 | -- Dumping data for table `c_posts` |
||
| 179 | -- |
||
| 180 | |||
| 181 | INSERT INTO `c_posts` (`post_id`, `topic_id`, `forum_id`, `poster_id`, `icon_id`, `poster_ip`, `post_time`, `post_reported`, `enable_bbcode`, `enable_smilies`, `enable_magic_url`, `enable_sig`, `post_username`, `post_subject`, `post_text`, `post_checksum`, `post_attachment`, `bbcode_bitfield`, `bbcode_uid`, `post_postcount`, `post_edit_time`, `post_edit_reason`, `post_edit_user`, `post_edit_count`, `post_edit_locked`, `post_visibility`, `post_delete_time`, `post_delete_reason`, `post_delete_user`) VALUES |
||
| 182 | (1, 1, 2, 2, 0, '127.0.0.1', 1343840387, 0, 1, 1, 1, 1, '', 'Welcome to phpBB3', 'This is an example post in your phpBB3 installation. Everything seems to be working. You may delete this post if you like and continue to set up your board. During the installation process your first category and your first forum are assigned an appropriate set of permissions for the predefined usergroups administrators, bots, global moderators, guests, registered users and registered COPPA users. If you also choose to delete your first category and your first forum, do not forget to assign permissions for all these usergroups for all new categories and forums you create. It is recommended to rename your first category and your first forum and copy permissions from these while creating new categories and forums. Have fun!', '5dd683b17f641daf84c040bfefc58ce9', 0, '', '', 1, 0, '', 0, 0, 0, 1, 0, '', 0), |
||
| 183 | (2, 2, 14, 2, 0, '127.0.0.1', 1376676604, 0, 1, 1, 1, 1, '', 'this should not show if it does die', 'No Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.', '08a963224e1894a0f6ded63172f818d2', 0, '', '1fzugufv', 1, 0, '', 0, 0, 0, 1, 0, '', 0), |
||
| 184 | (3, 3, 14, 2, 0, '127.0.0.1', 1376676710, 0, 1, 1, 1, 1, '', 'another', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'bdf55c952333a4f0992f429e152f03f7', 0, '', '1yurb15i', 1, 0, '', 0, 0, 0, 1, 0, '', 0), |
||
| 185 | (4, 4, 14, 2, 0, '127.0.0.1', 1376676762, 0, 1, 1, 1, 1, '', 'third', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'bdf55c952333a4f0992f429e152f03f7', 0, '', '2y44jt86', 1, 0, '', 0, 0, 0, 1, 0, '', 0), |
||
| 186 | (5, 5, 14, 2, 0, '127.0.0.1', 1376676815, 0, 1, 1, 1, 1, '', 'show', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'bdf55c952333a4f0992f429e152f03f7', 0, '', '32fdkg1c', 1, 0, '', 0, 0, 0, 1, 0, '', 0); |
||
| 187 | "; |
||
| 188 | break; |
||
| 189 | |||
| 190 | case 'c_topics': |
||
| 191 | $sql = " |
||
| 192 | CREATE TABLE IF NOT EXISTS `c_topics` ( |
||
| 193 | `topic_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, |
||
| 194 | `forum_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 195 | `icon_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 196 | `topic_attachment` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 197 | `topic_reported` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 198 | `topic_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', |
||
| 199 | `topic_poster` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 200 | `topic_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 201 | `topic_time_limit` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 202 | `topic_views` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 203 | `topic_status` tinyint(3) NOT NULL DEFAULT '0', |
||
| 204 | `topic_type` tinyint(3) NOT NULL DEFAULT '0', |
||
| 205 | `topic_first_post_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 206 | `topic_first_poster_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 207 | `topic_first_poster_colour` varchar(6) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 208 | `topic_last_post_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 209 | `topic_last_poster_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 210 | `topic_last_poster_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 211 | `topic_last_poster_colour` varchar(6) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 212 | `topic_last_post_subject` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 213 | `topic_last_post_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 214 | `topic_last_view_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 215 | `topic_moved_id` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 216 | `topic_bumped` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 217 | `topic_bumper` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 218 | `poll_title` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 219 | `poll_start` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 220 | `poll_length` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 221 | `poll_max_options` tinyint(4) NOT NULL DEFAULT '1', |
||
| 222 | `poll_last_vote` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 223 | `poll_vote_change` tinyint(1) unsigned NOT NULL DEFAULT '0', |
||
| 224 | `topic_visibility` tinyint(3) NOT NULL DEFAULT '0', |
||
| 225 | `topic_delete_time` int(11) unsigned NOT NULL DEFAULT '0', |
||
| 226 | `topic_delete_reason` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', |
||
| 227 | `topic_delete_user` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 228 | `topic_posts_approved` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 229 | `topic_posts_unapproved` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 230 | `topic_posts_softdeleted` mediumint(8) unsigned NOT NULL DEFAULT '0', |
||
| 231 | PRIMARY KEY (`topic_id`), |
||
| 232 | KEY `forum_id` (`forum_id`), |
||
| 233 | KEY `forum_id_type` (`forum_id`,`topic_type`), |
||
| 234 | KEY `last_post_time` (`topic_last_post_time`), |
||
| 235 | KEY `fid_time_moved` (`forum_id`,`topic_last_post_time`,`topic_moved_id`), |
||
| 236 | KEY `topic_visibility` (`topic_visibility`), |
||
| 237 | KEY `forum_vis_last` (`forum_id`,`topic_visibility`,`topic_last_post_id`) |
||
| 238 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=6 ; |
||
| 239 | |||
| 240 | -- |
||
| 241 | -- Dumping data for table `c_topics` |
||
| 242 | -- |
||
| 243 | |||
| 244 | INSERT INTO `c_topics` (`topic_id`, `forum_id`, `icon_id`, `topic_attachment`, `topic_reported`, `topic_title`, `topic_poster`, `topic_time`, `topic_time_limit`, `topic_views`, `topic_status`, `topic_type`, `topic_first_post_id`, `topic_first_poster_name`, `topic_first_poster_colour`, `topic_last_post_id`, `topic_last_poster_id`, `topic_last_poster_name`, `topic_last_poster_colour`, `topic_last_post_subject`, `topic_last_post_time`, `topic_last_view_time`, `topic_moved_id`, `topic_bumped`, `topic_bumper`, `poll_title`, `poll_start`, `poll_length`, `poll_max_options`, `poll_last_vote`, `poll_vote_change`, `topic_visibility`, `topic_delete_time`, `topic_delete_reason`, `topic_delete_user`, `topic_posts_approved`, `topic_posts_unapproved`, `topic_posts_softdeleted`) VALUES |
||
| 245 | (1, 2, 0, 0, 0, 'Welcome to phpBB3', 2, 1343840387, 0, 2, 0, 0, 1, 'UKB', '000000', 1, 2, 'UKB', '000000', 'Welcome to phpBB3', 1343840387, 1405344757, 0, 0, 0, '', 0, 0, 1, 0, 0, 1, 0, '', 0, 1, 0, 0), |
||
| 246 | (2, 14, 0, 0, 0, 'this should not show if it does die', 2, 1376676604, 0, 2, 0, 0, 2, 'UKB', '000000', 2, 2, 'UKB', '000000', 'this should not show if it does die', 1376676604, 1376677290, 0, 0, 0, '', 0, 0, 0, 0, 0, 1, 0, '', 0, 1, 0, 0), |
||
| 247 | (3, 14, 0, 0, 0, 'another', 2, 1376676710, 0, 1, 0, 0, 3, 'UKB', '000000', 3, 2, 'UKB', '000000', 'another', 1376676710, 1376677005, 0, 0, 0, '', 0, 0, 0, 0, 0, 1, 0, '', 0, 1, 0, 0), |
||
| 248 | (4, 14, 0, 0, 0, 'third', 2, 1376676762, 0, 1, 0, 0, 4, 'UKB', '000000', 4, 2, 'UKB', '000000', 'third', 1376676762, 1376677091, 0, 0, 0, '', 0, 0, 0, 0, 0, 1, 0, '', 0, 1, 0, 0), |
||
| 249 | (5, 14, 0, 0, 0, 'show', 2, 1376676815, 0, 1, 0, 0, 5, 'UKB', '000000', 5, 2, 'UKB', '000000', 'show', 1376676815, 1376677160, 0, 0, 0, '', 0, 0, 0, 0, 0, 1, 0, '', 0, 1, 0, 0); |
||
| 250 | "; |
||
| 251 | break; |
||
| 252 | } |
||
| 253 | |||
| 254 | return (isset($sql) ? $sql : null); |
||
| 255 | } |
||
| 256 | |||
| 329 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: