| Conditions | 14 |
| Paths | 89 |
| Total Lines | 45 |
| Code Lines | 22 |
| 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 |
||
| 45 | public static function connect($group = null, bool $shared = true): ConnectionInterface |
||
| 46 | { |
||
| 47 | // Si on a deja passer une connection, pas la peine de continuer |
||
| 48 | if ($group instanceof ConnectionInterface) { |
||
| 49 | return $group; |
||
| 50 | } |
||
| 51 | |||
| 52 | if (is_array($group)) { |
||
| 53 | $config = $group; |
||
| 54 | $group = 'custom-' . md5(json_encode($config)); |
||
| 55 | } |
||
| 56 | |||
| 57 | $config ??= config('database'); |
||
| 58 | |||
| 59 | if (empty($group)) { |
||
| 60 | $group = $config['group'] ?? 'auto'; |
||
| 61 | |||
| 62 | if ($group === 'auto') { |
||
| 63 | $group = on_test() ? 'test' : (on_prod() ? 'production' : 'development'); |
||
| 64 | } |
||
| 65 | |||
| 66 | if (! isset($config[$group])) { |
||
| 67 | $group = 'default'; |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | if (is_string($group) && ! isset($config[$group]) && strpos($group, 'custom-') !== 0) { |
||
| 72 | throw new InvalidArgumentException($group . ' is not a valid database connection group.'); |
||
| 73 | } |
||
| 74 | |||
| 75 | if ($shared && isset(static::$instances[$group])) { |
||
| 76 | return static::$instances[$group]; |
||
| 77 | } |
||
| 78 | |||
| 79 | static::ensureFactory(); |
||
| 80 | |||
| 81 | if (isset($config[$group])) { |
||
| 82 | $config = $config[$group]; |
||
| 83 | } |
||
| 84 | |||
| 85 | $connection = static::$factory->load($config, $group); |
||
| 86 | |||
| 87 | static::$instances[$group] = &$connection; |
||
| 88 | |||
| 89 | return $connection; |
||
| 90 | } |
||
| 141 |
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