| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 116 | 
| Code Lines | 85 | 
| 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  | 
            ||
| 169 | public function databaseUrls()  | 
            ||
| 170 |     { | 
            ||
| 171 | return array(  | 
            ||
| 172 | 'simple URL' => array(  | 
            ||
| 173 | 'mysql://foo:bar@localhost/baz',  | 
            ||
| 174 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 175 | ),  | 
            ||
| 176 | 'simple URL with port' => array(  | 
            ||
| 177 | 'mysql://foo:bar@localhost:11211/baz',  | 
            ||
| 178 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'port' => 11211, 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 179 | ),  | 
            ||
| 180 | 'sqlite relative URL with host' => array(  | 
            ||
| 181 | 'sqlite://localhost/foo/dbname.sqlite',  | 
            ||
| 182 |                 array('path' => 'foo/dbname.sqlite', 'driver' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver'), | 
            ||
| 183 | ),  | 
            ||
| 184 | 'sqlite absolute URL with host' => array(  | 
            ||
| 185 | 'sqlite://localhost//tmp/dbname.sqlite',  | 
            ||
| 186 |                 array('path' => '/tmp/dbname.sqlite', 'driver' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver'), | 
            ||
| 187 | ),  | 
            ||
| 188 | 'sqlite relative URL without host' => array(  | 
            ||
| 189 | 'sqlite:///foo/dbname.sqlite',  | 
            ||
| 190 |                 array('path' => 'foo/dbname.sqlite', 'driver' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver'), | 
            ||
| 191 | ),  | 
            ||
| 192 | 'sqlite absolute URL without host' => array(  | 
            ||
| 193 | 'sqlite:////tmp/dbname.sqlite',  | 
            ||
| 194 |                 array('path' => '/tmp/dbname.sqlite', 'driver' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver'), | 
            ||
| 195 | ),  | 
            ||
| 196 | 'sqlite memory' => array(  | 
            ||
| 197 | 'sqlite:///:memory:',  | 
            ||
| 198 |                 array('memory' => true, 'driver' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver'), | 
            ||
| 199 | ),  | 
            ||
| 200 | 'sqlite memory with host' => array(  | 
            ||
| 201 | 'sqlite://localhost/:memory:',  | 
            ||
| 202 |                 array('memory' => true, 'driver' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver'), | 
            ||
| 203 | ),  | 
            ||
| 204 | 'params parsed from URL override individual params' => array(  | 
            ||
| 205 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'password' => 'lulz'), | 
            ||
| 206 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 207 | ),  | 
            ||
| 208 | 'params not parsed from URL but individual params are preserved' => array(  | 
            ||
| 209 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'port' => 1234), | 
            ||
| 210 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'port' => 1234, 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 211 | ),  | 
            ||
| 212 | 'query params from URL are used as extra params' => array(  | 
            ||
| 213 | 'url' => 'mysql://foo:bar@localhost/dbname?charset=UTF-8',  | 
            ||
| 214 |                 array('charset' => 'UTF-8'), | 
            ||
| 215 | ),  | 
            ||
| 216 | 'simple URL with fallthrough scheme not defined in map' => array(  | 
            ||
| 217 | 'sqlsrv://foo:bar@localhost/baz',  | 
            ||
| 218 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\SQLSrv\Driver'), | 
            ||
| 219 | ),  | 
            ||
| 220 | 'simple URL with fallthrough scheme containing underscores fails' => array(  | 
            ||
| 221 | 'drizzle_pdo_mysql://foo:bar@localhost/baz',  | 
            ||
| 222 | false,  | 
            ||
| 223 | ),  | 
            ||
| 224 | 'simple URL with fallthrough scheme containing dashes works' => array(  | 
            ||
| 225 | 'drizzle-pdo-mysql://foo:bar@localhost/baz',  | 
            ||
| 226 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver'), | 
            ||
| 227 | ),  | 
            ||
| 228 | 'simple URL with percent encoding' => array(  | 
            ||
| 229 | 'mysql://foo%3A:bar%2F@localhost/baz+baz%40',  | 
            ||
| 230 |                 array('user' => 'foo:', 'password' => 'bar/', 'host' => 'localhost', 'dbname' => 'baz+baz@', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 231 | ),  | 
            ||
| 232 | 'simple URL with percent sign in password' => array(  | 
            ||
| 233 | 'mysql://foo:bar%25bar@localhost/baz',  | 
            ||
| 234 |                 array('user' => 'foo', 'password' => 'bar%bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 235 | ),  | 
            ||
| 236 | |||
| 237 | // DBAL-1234  | 
            ||
| 238 | 'URL without scheme and without any driver information' => array(  | 
            ||
| 239 |                 array('url' => '//foo:bar@localhost/baz'), | 
            ||
| 240 | false,  | 
            ||
| 241 | ),  | 
            ||
| 242 | 'URL without scheme but default PDO driver' => array(  | 
            ||
| 243 |                 array('url' => '//foo:bar@localhost/baz', 'pdo' => true), | 
            ||
| 244 | false,  | 
            ||
| 245 | ),  | 
            ||
| 246 | 'URL without scheme but default driver' => array(  | 
            ||
| 247 |                 array('url' => '//foo:bar@localhost/baz', 'driver' => 'pdo_mysql'), | 
            ||
| 248 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 249 | ),  | 
            ||
| 250 | 'URL without scheme but custom driver' => array(  | 
            ||
| 251 |                 array('url' => '//foo:bar@localhost/baz', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 252 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 253 | ),  | 
            ||
| 254 | 'URL without scheme but default PDO driver and default driver' => array(  | 
            ||
| 255 |                 array('url' => '//foo:bar@localhost/baz', 'pdo' => true, 'driver' => 'pdo_mysql'), | 
            ||
| 256 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 257 | ),  | 
            ||
| 258 | 'URL without scheme but driver and custom driver' => array(  | 
            ||
| 259 |                 array('url' => '//foo:bar@localhost/baz', 'driver' => 'pdo_mysql', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 260 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 261 | ),  | 
            ||
| 262 | 'URL with default PDO driver' => array(  | 
            ||
| 263 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'pdo' => true), | 
            ||
| 264 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 265 | ),  | 
            ||
| 266 | 'URL with default driver' => array(  | 
            ||
| 267 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'driver' => 'sqlite'), | 
            ||
| 268 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 269 | ),  | 
            ||
| 270 | 'URL with default custom driver' => array(  | 
            ||
| 271 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 272 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 273 | ),  | 
            ||
| 274 | 'URL with default PDO driver and default driver' => array(  | 
            ||
| 275 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'pdo' => true, 'driver' => 'sqlite'), | 
            ||
| 276 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 277 | ),  | 
            ||
| 278 | 'URL with default driver and default custom driver' => array(  | 
            ||
| 279 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'driver' => 'sqlite',  'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 280 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 281 | ),  | 
            ||
| 282 | 'URL with default PDO driver and default driver and default custom driver' => array(  | 
            ||
| 283 |                 array('url' => 'mysql://foo:bar@localhost/baz', 'pdo' => true, 'driver' => 'sqlite', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock'), | 
            ||
| 284 |                 array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'dbname' => 'baz', 'driver' => 'Doctrine\DBAL\Driver\PDOMySQL\Driver'), | 
            ||
| 285 | ),  | 
            ||
| 289 |