| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 228 | 
| Code Lines | 146 | 
| 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  | 
            ||
| 195 | public function databaseUrls()  | 
            ||
| 196 |     { | 
            ||
| 197 | $driver = $this->createMock(Driver::class);  | 
            ||
| 198 | $driverClass = get_class($driver);  | 
            ||
| 199 | |||
| 200 | return [  | 
            ||
| 201 | 'simple URL' => [  | 
            ||
| 202 | 'mysql://foo:bar@localhost/baz',  | 
            ||
| 203 | [  | 
            ||
| 204 | 'user' => 'foo',  | 
            ||
| 205 | 'password' => 'bar',  | 
            ||
| 206 | 'host' => 'localhost',  | 
            ||
| 207 | 'dbname' => 'baz',  | 
            ||
| 208 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 209 | ],  | 
            ||
| 210 | ],  | 
            ||
| 211 | 'simple URL with port' => [  | 
            ||
| 212 | 'mysql://foo:bar@localhost:11211/baz',  | 
            ||
| 213 | [  | 
            ||
| 214 | 'user' => 'foo',  | 
            ||
| 215 | 'password' => 'bar',  | 
            ||
| 216 | 'host' => 'localhost',  | 
            ||
| 217 | 'port' => 11211,  | 
            ||
| 218 | 'dbname' => 'baz',  | 
            ||
| 219 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 220 | ],  | 
            ||
| 221 | ],  | 
            ||
| 222 | 'sqlite relative URL with host' => [  | 
            ||
| 223 | 'sqlite://localhost/foo/dbname.sqlite',  | 
            ||
| 224 | [  | 
            ||
| 225 | 'path' => 'foo/dbname.sqlite',  | 
            ||
| 226 | 'driver' => PDOSqliteDriver::class,  | 
            ||
| 227 | ],  | 
            ||
| 228 | ],  | 
            ||
| 229 | 'sqlite absolute URL with host' => [  | 
            ||
| 230 | 'sqlite://localhost//tmp/dbname.sqlite',  | 
            ||
| 231 | [  | 
            ||
| 232 | 'path' => '/tmp/dbname.sqlite',  | 
            ||
| 233 | 'driver' => PDOSqliteDriver::class,  | 
            ||
| 234 | ],  | 
            ||
| 235 | ],  | 
            ||
| 236 | 'sqlite relative URL without host' => [  | 
            ||
| 237 | 'sqlite:///foo/dbname.sqlite',  | 
            ||
| 238 | [  | 
            ||
| 239 | 'path' => 'foo/dbname.sqlite',  | 
            ||
| 240 | 'driver' => PDOSqliteDriver::class,  | 
            ||
| 241 | ],  | 
            ||
| 242 | ],  | 
            ||
| 243 | 'sqlite absolute URL without host' => [  | 
            ||
| 244 | 'sqlite:////tmp/dbname.sqlite',  | 
            ||
| 245 | [  | 
            ||
| 246 | 'path' => '/tmp/dbname.sqlite',  | 
            ||
| 247 | 'driver' => PDOSqliteDriver::class,  | 
            ||
| 248 | ],  | 
            ||
| 249 | ],  | 
            ||
| 250 | 'sqlite memory' => [  | 
            ||
| 251 | 'sqlite:///:memory:',  | 
            ||
| 252 | [  | 
            ||
| 253 | 'memory' => true,  | 
            ||
| 254 | 'driver' => PDOSqliteDriver::class,  | 
            ||
| 255 | ],  | 
            ||
| 256 | ],  | 
            ||
| 257 | 'sqlite memory with host' => [  | 
            ||
| 258 | 'sqlite://localhost/:memory:',  | 
            ||
| 259 | [  | 
            ||
| 260 | 'memory' => true,  | 
            ||
| 261 | 'driver' => PDOSqliteDriver::class,  | 
            ||
| 262 | ],  | 
            ||
| 263 | ],  | 
            ||
| 264 | 'params parsed from URL override individual params' => [  | 
            ||
| 265 | [  | 
            ||
| 266 | 'url' => 'mysql://foo:bar@localhost/baz',  | 
            ||
| 267 | 'password' => 'lulz',  | 
            ||
| 268 | ],  | 
            ||
| 269 | [  | 
            ||
| 270 | 'user' => 'foo',  | 
            ||
| 271 | 'password' => 'bar',  | 
            ||
| 272 | 'host' => 'localhost',  | 
            ||
| 273 | 'dbname' => 'baz',  | 
            ||
| 274 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 275 | ],  | 
            ||
| 276 | ],  | 
            ||
| 277 | 'params not parsed from URL but individual params are preserved' => [  | 
            ||
| 278 | [  | 
            ||
| 279 | 'url' => 'mysql://foo:bar@localhost/baz',  | 
            ||
| 280 | 'port' => 1234,  | 
            ||
| 281 | ],  | 
            ||
| 282 | [  | 
            ||
| 283 | 'user' => 'foo',  | 
            ||
| 284 | 'password' => 'bar',  | 
            ||
| 285 | 'host' => 'localhost',  | 
            ||
| 286 | 'port' => 1234,  | 
            ||
| 287 | 'dbname' => 'baz',  | 
            ||
| 288 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 289 | ],  | 
            ||
| 290 | ],  | 
            ||
| 291 | 'query params from URL are used as extra params' => [  | 
            ||
| 292 | 'url' => 'mysql://foo:bar@localhost/dbname?charset=UTF-8',  | 
            ||
| 293 | ['charset' => 'UTF-8'],  | 
            ||
| 294 | ],  | 
            ||
| 295 | 'simple URL with fallthrough scheme not defined in map' => [  | 
            ||
| 296 | 'sqlsrv://foo:bar@localhost/baz',  | 
            ||
| 297 | [  | 
            ||
| 298 | 'user' => 'foo',  | 
            ||
| 299 | 'password' => 'bar',  | 
            ||
| 300 | 'host' => 'localhost',  | 
            ||
| 301 | 'dbname' => 'baz',  | 
            ||
| 302 | 'driver' => SQLSrvDriver::class,  | 
            ||
| 303 | ],  | 
            ||
| 304 | ],  | 
            ||
| 305 | 'simple URL with fallthrough scheme containing underscores fails' => [  | 
            ||
| 306 | 'pdo_mysql://foo:bar@localhost/baz',  | 
            ||
| 307 | false,  | 
            ||
| 308 | ],  | 
            ||
| 309 | 'simple URL with fallthrough scheme containing dashes works' => [  | 
            ||
| 310 | 'pdo-mysql://foo:bar@localhost/baz',  | 
            ||
| 311 | [  | 
            ||
| 312 | 'user' => 'foo',  | 
            ||
| 313 | 'password' => 'bar',  | 
            ||
| 314 | 'host' => 'localhost',  | 
            ||
| 315 | 'dbname' => 'baz',  | 
            ||
| 316 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 317 | ],  | 
            ||
| 318 | ],  | 
            ||
| 319 | 'simple URL with percent encoding' => [  | 
            ||
| 320 | 'mysql://foo%3A:bar%2F@localhost/baz+baz%40',  | 
            ||
| 321 | [  | 
            ||
| 322 | 'user' => 'foo:',  | 
            ||
| 323 | 'password' => 'bar/',  | 
            ||
| 324 | 'host' => 'localhost',  | 
            ||
| 325 | 'dbname' => 'baz+baz@',  | 
            ||
| 326 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 327 | ],  | 
            ||
| 328 | ],  | 
            ||
| 329 | 'simple URL with percent sign in password' => [  | 
            ||
| 330 | 'mysql://foo:bar%25bar@localhost/baz',  | 
            ||
| 331 | [  | 
            ||
| 332 | 'user' => 'foo',  | 
            ||
| 333 | 'password' => 'bar%bar',  | 
            ||
| 334 | 'host' => 'localhost',  | 
            ||
| 335 | 'dbname' => 'baz',  | 
            ||
| 336 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 337 | ],  | 
            ||
| 338 | ],  | 
            ||
| 339 | |||
| 340 | // DBAL-1234  | 
            ||
| 341 | 'URL without scheme and without any driver information' => [  | 
            ||
| 342 | ['url' => '//foo:bar@localhost/baz'],  | 
            ||
| 343 | false,  | 
            ||
| 344 | ],  | 
            ||
| 345 | 'URL without scheme but default driver' => [  | 
            ||
| 346 | [  | 
            ||
| 347 | 'url' => '//foo:bar@localhost/baz',  | 
            ||
| 348 | 'driver' => 'pdo_mysql',  | 
            ||
| 349 | ],  | 
            ||
| 350 | [  | 
            ||
| 351 | 'user' => 'foo',  | 
            ||
| 352 | 'password' => 'bar',  | 
            ||
| 353 | 'host' => 'localhost',  | 
            ||
| 354 | 'dbname' => 'baz',  | 
            ||
| 355 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 356 | ],  | 
            ||
| 357 | ],  | 
            ||
| 358 | 'URL without scheme but custom driver' => [  | 
            ||
| 359 | [  | 
            ||
| 360 | 'url' => '//foo:bar@localhost/baz',  | 
            ||
| 361 | 'driverClass' => $driverClass,  | 
            ||
| 362 | ],  | 
            ||
| 363 | [  | 
            ||
| 364 | 'user' => 'foo',  | 
            ||
| 365 | 'password' => 'bar',  | 
            ||
| 366 | 'host' => 'localhost',  | 
            ||
| 367 | 'dbname' => 'baz',  | 
            ||
| 368 | 'driverClass' => $driverClass,  | 
            ||
| 369 | ],  | 
            ||
| 370 | ],  | 
            ||
| 371 | 'URL without scheme but driver and custom driver' => [  | 
            ||
| 372 | [  | 
            ||
| 373 | 'url' => '//foo:bar@localhost/baz',  | 
            ||
| 374 | 'driver' => 'pdo_mysql',  | 
            ||
| 375 | 'driverClass' => $driverClass,  | 
            ||
| 376 | ],  | 
            ||
| 377 | [  | 
            ||
| 378 | 'user' => 'foo',  | 
            ||
| 379 | 'password' => 'bar',  | 
            ||
| 380 | 'host' => 'localhost',  | 
            ||
| 381 | 'dbname' => 'baz',  | 
            ||
| 382 | 'driverClass' => $driverClass,  | 
            ||
| 383 | ],  | 
            ||
| 384 | ],  | 
            ||
| 385 | 'URL with default driver' => [  | 
            ||
| 386 | [  | 
            ||
| 387 | 'url' => 'mysql://foo:bar@localhost/baz',  | 
            ||
| 388 | 'driver' => 'sqlite',  | 
            ||
| 389 | ],  | 
            ||
| 390 | [  | 
            ||
| 391 | 'user' => 'foo',  | 
            ||
| 392 | 'password' => 'bar',  | 
            ||
| 393 | 'host' => 'localhost',  | 
            ||
| 394 | 'dbname' => 'baz',  | 
            ||
| 395 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 396 | ],  | 
            ||
| 397 | ],  | 
            ||
| 398 | 'URL with default custom driver' => [  | 
            ||
| 399 | [  | 
            ||
| 400 | 'url' => 'mysql://foo:bar@localhost/baz',  | 
            ||
| 401 | 'driverClass' => $driverClass,  | 
            ||
| 402 | ],  | 
            ||
| 403 | [  | 
            ||
| 404 | 'user' => 'foo',  | 
            ||
| 405 | 'password' => 'bar',  | 
            ||
| 406 | 'host' => 'localhost',  | 
            ||
| 407 | 'dbname' => 'baz',  | 
            ||
| 408 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 409 | ],  | 
            ||
| 410 | ],  | 
            ||
| 411 | 'URL with default driver and default custom driver' => [  | 
            ||
| 412 | [  | 
            ||
| 413 | 'url' => 'mysql://foo:bar@localhost/baz',  | 
            ||
| 414 | 'driver' => 'sqlite',  | 
            ||
| 415 | 'driverClass' => $driverClass,  | 
            ||
| 416 | ],  | 
            ||
| 417 | [  | 
            ||
| 418 | 'user' => 'foo',  | 
            ||
| 419 | 'password' => 'bar',  | 
            ||
| 420 | 'host' => 'localhost',  | 
            ||
| 421 | 'dbname' => 'baz',  | 
            ||
| 422 | 'driver' => PDOMySQLDriver::class,  | 
            ||
| 423 | ],  | 
            ||
| 428 |