| Conditions | 11 |
| Paths | 1024 |
| Total Lines | 361 |
| Code Lines | 262 |
| 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 |
||
| 31 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
||
| 32 | /** @var ISchemaWrapper $schema */ |
||
| 33 | $schema = $schemaClosure(); |
||
| 34 | |||
| 35 | if (!$schema->hasTable('music_artists')) { |
||
| 36 | $table = $schema->createTable('music_artists'); |
||
| 37 | $table->addColumn('id', 'integer', [ |
||
| 38 | 'autoincrement' => true, |
||
| 39 | 'notnull' => true, |
||
| 40 | 'unsigned' => true, |
||
| 41 | ]); |
||
| 42 | $table->addColumn('user_id', 'string', [ |
||
| 43 | 'notnull' => true, |
||
| 44 | 'length' => 64, |
||
| 45 | ]); |
||
| 46 | $table->addColumn('name', 'string', [ |
||
| 47 | 'notnull' => false, |
||
| 48 | 'length' => 256, |
||
| 49 | ]); |
||
| 50 | $table->addColumn('cover_file_id', 'bigint', [ |
||
| 51 | 'notnull' => false, |
||
| 52 | 'length' => 10, |
||
| 53 | ]); |
||
| 54 | $table->addColumn('mbid', 'string', [ |
||
| 55 | 'notnull' => false, |
||
| 56 | 'length' => 36, |
||
| 57 | ]); |
||
| 58 | $table->addColumn('hash', 'string', [ |
||
| 59 | 'notnull' => true, |
||
| 60 | 'length' => 32, |
||
| 61 | ]); |
||
| 62 | $table->addColumn('starred', 'datetime', [ |
||
| 63 | 'notnull' => false, |
||
| 64 | ]); |
||
| 65 | $table->addColumn('created', 'datetime', [ |
||
| 66 | 'notnull' => false, |
||
| 67 | ]); |
||
| 68 | $table->addColumn('updated', 'datetime', [ |
||
| 69 | 'notnull' => false, |
||
| 70 | ]); |
||
| 71 | $table->setPrimaryKey(['id']); |
||
| 72 | $table->addUniqueIndex(['user_id', 'hash'], 'user_id_hash_idx'); |
||
| 73 | } |
||
| 74 | |||
| 75 | if (!$schema->hasTable('music_albums')) { |
||
| 76 | $table = $schema->createTable('music_albums'); |
||
| 77 | $table->addColumn('id', 'integer', [ |
||
| 78 | 'autoincrement' => true, |
||
| 79 | 'notnull' => true, |
||
| 80 | 'unsigned' => true, |
||
| 81 | ]); |
||
| 82 | $table->addColumn('user_id', 'string', [ |
||
| 83 | 'notnull' => true, |
||
| 84 | 'length' => 64, |
||
| 85 | ]); |
||
| 86 | $table->addColumn('name', 'string', [ |
||
| 87 | 'notnull' => false, |
||
| 88 | 'length' => 256, |
||
| 89 | ]); |
||
| 90 | $table->addColumn('cover_file_id', 'bigint', [ |
||
| 91 | 'notnull' => false, |
||
| 92 | 'length' => 10, |
||
| 93 | ]); |
||
| 94 | $table->addColumn('mbid', 'string', [ |
||
| 95 | 'notnull' => false, |
||
| 96 | 'length' => 36, |
||
| 97 | ]); |
||
| 98 | $table->addColumn('disk', 'integer', [ |
||
| 99 | 'notnull' => false, |
||
| 100 | 'unsigned' => true, |
||
| 101 | ]); |
||
| 102 | $table->addColumn('mbid_group', 'string', [ |
||
| 103 | 'notnull' => false, |
||
| 104 | 'length' => 36, |
||
| 105 | ]); |
||
| 106 | $table->addColumn('album_artist_id', 'integer', [ |
||
| 107 | 'notnull' => false, |
||
| 108 | ]); |
||
| 109 | $table->addColumn('hash', 'string', [ |
||
| 110 | 'notnull' => true, |
||
| 111 | 'length' => 32, |
||
| 112 | ]); |
||
| 113 | $table->addColumn('starred', 'datetime', [ |
||
| 114 | 'notnull' => false, |
||
| 115 | ]); |
||
| 116 | $table->addColumn('created', 'datetime', [ |
||
| 117 | 'notnull' => false, |
||
| 118 | ]); |
||
| 119 | $table->addColumn('updated', 'datetime', [ |
||
| 120 | 'notnull' => false, |
||
| 121 | ]); |
||
| 122 | $table->setPrimaryKey(['id']); |
||
| 123 | $table->addIndex(['cover_file_id'], 'ma_cover_file_id_idx'); |
||
| 124 | $table->addIndex(['album_artist_id'], 'ma_album_artist_id_idx'); |
||
| 125 | $table->addUniqueIndex(['user_id', 'hash'], 'ma_user_id_hash_idx'); |
||
| 126 | } |
||
| 127 | |||
| 128 | if (!$schema->hasTable('music_tracks')) { |
||
| 129 | $table = $schema->createTable('music_tracks'); |
||
| 130 | $table->addColumn('id', 'integer', [ |
||
| 131 | 'autoincrement' => true, |
||
| 132 | 'notnull' => true, |
||
| 133 | 'unsigned' => true, |
||
| 134 | ]); |
||
| 135 | $table->addColumn('user_id', 'string', [ |
||
| 136 | 'notnull' => true, |
||
| 137 | 'length' => 64, |
||
| 138 | ]); |
||
| 139 | $table->addColumn('title', 'string', [ |
||
| 140 | 'notnull' => true, |
||
| 141 | 'length' => 256, |
||
| 142 | ]); |
||
| 143 | $table->addColumn('number', 'integer', [ |
||
| 144 | 'notnull' => false, |
||
| 145 | 'unsigned' => true, |
||
| 146 | ]); |
||
| 147 | $table->addColumn('disk', 'integer', [ |
||
| 148 | 'notnull' => false, |
||
| 149 | 'unsigned' => true, |
||
| 150 | ]); |
||
| 151 | $table->addColumn('year', 'integer', [ |
||
| 152 | 'notnull' => false, |
||
| 153 | 'unsigned' => true, |
||
| 154 | ]); |
||
| 155 | $table->addColumn('artist_id', 'integer', [ |
||
| 156 | 'notnull' => false, |
||
| 157 | ]); |
||
| 158 | $table->addColumn('album_id', 'integer', [ |
||
| 159 | 'notnull' => false, |
||
| 160 | ]); |
||
| 161 | $table->addColumn('length', 'integer', [ |
||
| 162 | 'notnull' => false, |
||
| 163 | 'unsigned' => true, |
||
| 164 | ]); |
||
| 165 | $table->addColumn('file_id', 'bigint', [ |
||
| 166 | 'notnull' => true, |
||
| 167 | 'length' => 10, |
||
| 168 | ]); |
||
| 169 | $table->addColumn('bitrate', 'integer', [ |
||
| 170 | 'notnull' => false, |
||
| 171 | 'unsigned' => true, |
||
| 172 | ]); |
||
| 173 | $table->addColumn('mimetype', 'string', [ |
||
| 174 | 'notnull' => true, |
||
| 175 | 'length' => 256, |
||
| 176 | ]); |
||
| 177 | $table->addColumn('mbid', 'string', [ |
||
| 178 | 'notnull' => false, |
||
| 179 | 'length' => 36, |
||
| 180 | ]); |
||
| 181 | $table->addColumn('starred', 'datetime', [ |
||
| 182 | 'notnull' => false, |
||
| 183 | ]); |
||
| 184 | $table->addColumn('genre_id', 'integer', [ |
||
| 185 | 'notnull' => false, |
||
| 186 | 'unsigned' => true, |
||
| 187 | ]); |
||
| 188 | $table->addColumn('created', 'datetime', [ |
||
| 189 | 'notnull' => false, |
||
| 190 | ]); |
||
| 191 | $table->addColumn('updated', 'datetime', [ |
||
| 192 | 'notnull' => false, |
||
| 193 | ]); |
||
| 194 | $table->setPrimaryKey(['id']); |
||
| 195 | $table->addIndex(['artist_id'], 'music_tracks_artist_id_idx'); |
||
| 196 | $table->addIndex(['album_id'], 'music_tracks_album_id_idx'); |
||
| 197 | $table->addIndex(['user_id'], 'music_tracks_user_id_idx'); |
||
| 198 | $table->addUniqueIndex(['file_id', 'user_id'], 'music_tracks_file_user_id_idx'); |
||
| 199 | } |
||
| 200 | |||
| 201 | if (!$schema->hasTable('music_playlists')) { |
||
| 202 | $table = $schema->createTable('music_playlists'); |
||
| 203 | $table->addColumn('id', 'integer', [ |
||
| 204 | 'autoincrement' => true, |
||
| 205 | 'notnull' => true, |
||
| 206 | 'unsigned' => true, |
||
| 207 | ]); |
||
| 208 | $table->addColumn('user_id', 'string', [ |
||
| 209 | 'notnull' => true, |
||
| 210 | 'length' => 64, |
||
| 211 | ]); |
||
| 212 | $table->addColumn('name', 'string', [ |
||
| 213 | 'notnull' => false, |
||
| 214 | 'length' => 256, |
||
| 215 | ]); |
||
| 216 | $table->addColumn('track_ids', 'text', [ |
||
| 217 | 'notnull' => false, |
||
| 218 | ]); |
||
| 219 | $table->addColumn('created', 'datetime', [ |
||
| 220 | 'notnull' => false, |
||
| 221 | ]); |
||
| 222 | $table->addColumn('updated', 'datetime', [ |
||
| 223 | 'notnull' => false, |
||
| 224 | ]); |
||
| 225 | $table->addColumn('comment', 'string', [ |
||
| 226 | 'notnull' => false, |
||
| 227 | 'length' => 256, |
||
| 228 | ]); |
||
| 229 | $table->setPrimaryKey(['id']); |
||
| 230 | } |
||
| 231 | |||
| 232 | if (!$schema->hasTable('music_genres')) { |
||
| 233 | $table = $schema->createTable('music_genres'); |
||
| 234 | $table->addColumn('id', 'integer', [ |
||
| 235 | 'autoincrement' => true, |
||
| 236 | 'notnull' => true, |
||
| 237 | 'unsigned' => true, |
||
| 238 | ]); |
||
| 239 | $table->addColumn('user_id', 'string', [ |
||
| 240 | 'notnull' => true, |
||
| 241 | 'length' => 64, |
||
| 242 | ]); |
||
| 243 | $table->addColumn('name', 'string', [ |
||
| 244 | 'notnull' => false, |
||
| 245 | 'length' => 64, |
||
| 246 | ]); |
||
| 247 | $table->addColumn('lower_name', 'string', [ |
||
| 248 | 'notnull' => false, |
||
| 249 | 'length' => 64, |
||
| 250 | ]); |
||
| 251 | $table->addColumn('created', 'datetime', [ |
||
| 252 | 'notnull' => false, |
||
| 253 | ]); |
||
| 254 | $table->addColumn('updated', 'datetime', [ |
||
| 255 | 'notnull' => false, |
||
| 256 | ]); |
||
| 257 | $table->setPrimaryKey(['id']); |
||
| 258 | $table->addUniqueIndex(['lower_name', 'user_id'], 'mg_lower_name_user_id_idx'); |
||
| 259 | } |
||
| 260 | |||
| 261 | if (!$schema->hasTable('music_radio_stations')) { |
||
| 262 | $table = $schema->createTable('music_radio_stations'); |
||
| 263 | $table->addColumn('id', 'integer', [ |
||
| 264 | 'autoincrement' => true, |
||
| 265 | 'notnull' => true, |
||
| 266 | 'unsigned' => true, |
||
| 267 | ]); |
||
| 268 | $table->addColumn('user_id', 'string', [ |
||
| 269 | 'notnull' => true, |
||
| 270 | 'length' => 64, |
||
| 271 | ]); |
||
| 272 | $table->addColumn('name', 'string', [ |
||
| 273 | 'notnull' => false, |
||
| 274 | 'length' => 256, |
||
| 275 | ]); |
||
| 276 | $table->addColumn('stream_url', 'string', [ |
||
| 277 | 'notnull' => true, |
||
| 278 | 'length' => 2048, |
||
| 279 | ]); |
||
| 280 | $table->addColumn('home_url', 'string', [ |
||
| 281 | 'notnull' => false, |
||
| 282 | 'length' => 2048, |
||
| 283 | ]); |
||
| 284 | $table->addColumn('created', 'datetime', [ |
||
| 285 | 'notnull' => false, |
||
| 286 | ]); |
||
| 287 | $table->addColumn('updated', 'datetime', [ |
||
| 288 | 'notnull' => false, |
||
| 289 | ]); |
||
| 290 | $table->setPrimaryKey(['id']); |
||
| 291 | } |
||
| 292 | |||
| 293 | if (!$schema->hasTable('music_ampache_sessions')) { |
||
| 294 | $table = $schema->createTable('music_ampache_sessions'); |
||
| 295 | $table->addColumn('id', 'integer', [ |
||
| 296 | 'autoincrement' => true, |
||
| 297 | 'notnull' => true, |
||
| 298 | 'unsigned' => true, |
||
| 299 | ]); |
||
| 300 | $table->addColumn('user_id', 'string', [ |
||
| 301 | 'notnull' => true, |
||
| 302 | 'length' => 64, |
||
| 303 | ]); |
||
| 304 | $table->addColumn('token', 'string', [ |
||
| 305 | 'notnull' => true, |
||
| 306 | 'length' => 64, |
||
| 307 | ]); |
||
| 308 | $table->addColumn('expiry', 'integer', [ |
||
| 309 | 'notnull' => true, |
||
| 310 | 'unsigned' => true, |
||
| 311 | ]); |
||
| 312 | $table->setPrimaryKey(['id']); |
||
| 313 | $table->addUniqueIndex(['token'], 'music_ampache_sessions_index'); |
||
| 314 | } |
||
| 315 | |||
| 316 | if (!$schema->hasTable('music_ampache_users')) { |
||
| 317 | $table = $schema->createTable('music_ampache_users'); |
||
| 318 | $table->addColumn('id', 'integer', [ |
||
| 319 | 'autoincrement' => true, |
||
| 320 | 'notnull' => true, |
||
| 321 | 'length' => 4, |
||
| 322 | ]); |
||
| 323 | $table->addColumn('user_id', 'string', [ |
||
| 324 | 'notnull' => true, |
||
| 325 | 'length' => 64, |
||
| 326 | ]); |
||
| 327 | $table->addColumn('description', 'string', [ |
||
| 328 | 'notnull' => false, |
||
| 329 | 'length' => 64, |
||
| 330 | ]); |
||
| 331 | $table->addColumn('hash', 'string', [ |
||
| 332 | 'notnull' => true, |
||
| 333 | 'length' => 64, |
||
| 334 | ]); |
||
| 335 | $table->setPrimaryKey(['id']); |
||
| 336 | $table->addUniqueIndex(['hash', 'user_id'], 'music_ampache_users_index'); |
||
| 337 | } |
||
| 338 | |||
| 339 | if (!$schema->hasTable('music_cache')) { |
||
| 340 | $table = $schema->createTable('music_cache'); |
||
| 341 | $table->addColumn('id', 'integer', [ |
||
| 342 | 'autoincrement' => true, |
||
| 343 | 'notnull' => true, |
||
| 344 | 'unsigned' => true, |
||
| 345 | ]); |
||
| 346 | $table->addColumn('key', 'string', [ |
||
| 347 | 'notnull' => true, |
||
| 348 | 'length' => 64, |
||
| 349 | ]); |
||
| 350 | $table->addColumn('user_id', 'string', [ |
||
| 351 | 'notnull' => true, |
||
| 352 | 'length' => 64, |
||
| 353 | ]); |
||
| 354 | $table->addColumn('data', 'text', [ |
||
| 355 | 'notnull' => false, |
||
| 356 | ]); |
||
| 357 | $table->setPrimaryKey(['id']); |
||
| 358 | $table->addUniqueIndex(['user_id', 'key'], 'music_cache_index'); |
||
| 359 | } |
||
| 360 | |||
| 361 | if (!$schema->hasTable('music_bookmarks')) { |
||
| 362 | $table = $schema->createTable('music_bookmarks'); |
||
| 363 | $table->addColumn('id', 'integer', [ |
||
| 364 | 'autoincrement' => true, |
||
| 365 | 'notnull' => true, |
||
| 366 | 'unsigned' => true, |
||
| 367 | ]); |
||
| 368 | $table->addColumn('user_id', 'string', [ |
||
| 369 | 'notnull' => true, |
||
| 370 | 'length' => 64, |
||
| 371 | ]); |
||
| 372 | $table->addColumn('track_id', 'integer', [ |
||
| 373 | 'notnull' => true, |
||
| 374 | ]); |
||
| 375 | $table->addColumn('position', 'integer', [ |
||
| 376 | 'notnull' => true, |
||
| 377 | ]); |
||
| 378 | $table->addColumn('comment', 'string', [ |
||
| 379 | 'notnull' => false, |
||
| 380 | 'length' => 256, |
||
| 381 | ]); |
||
| 382 | $table->addColumn('created', 'datetime', [ |
||
| 383 | 'notnull' => false, |
||
| 384 | ]); |
||
| 385 | $table->addColumn('updated', 'datetime', [ |
||
| 386 | 'notnull' => false, |
||
| 387 | ]); |
||
| 388 | $table->setPrimaryKey(['id']); |
||
| 389 | $table->addUniqueIndex(['user_id', 'track_id'], 'music_bookmarks_user_track'); |
||
| 390 | } |
||
| 391 | return $schema; |
||
| 392 | } |
||
| 402 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths