Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Lines | 9 |
Ratio | 50 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
29 | 2 | private function parseDsn(array &$config) |
|
30 | { |
||
31 | 2 | $config = \array_merge($config, \parse_url($config['dsn'])); |
|
32 | |||
33 | 2 | if (isset($config['pass'])) { |
|
34 | 1 | $config['password'] = $config['pass']; |
|
35 | // Cleanup |
||
36 | 1 | unset($config['pass']); |
|
37 | 1 | View Code Duplication | } elseif (isset($config['user'])) { |
38 | /* |
||
39 | * since "redis://my-super-secret-password@redis-host:6379" is a valid redis |
||
40 | * dsn but \parse_url does not understand this notation and extracts the auth as user, |
||
41 | * we need to check for it. |
||
42 | */ |
||
43 | 1 | $config['password'] = $config['user']; |
|
44 | 1 | unset($config['user']); |
|
45 | } |
||
46 | 2 | } |
|
47 | |||
53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.