| Conditions | 4 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 17 | public function connect($connection, $name = 'default') |
|
| 19 | { |
||
| 20 | 17 | if (!$connection instanceof Configuration) { |
|
| 21 | 17 | $connection = new Configuration($connection); |
|
|
|
|||
| 22 | } |
||
| 23 | 17 | if (!$connection instanceof ConnectionInterface) { |
|
| 24 | 17 | switch ($connection->getDriver()) { |
|
| 25 | 17 | case Configuration::DRIVER_MYSQL: |
|
| 26 | 16 | $connection = new MysqlConnection($connection); |
|
| 27 | 16 | break; |
|
| 28 | default: |
||
| 29 | 1 | throw new DriverNotFoundException($connection->getDriver()); |
|
| 30 | } |
||
| 31 | } |
||
| 32 | 16 | $connection->connect(); |
|
| 33 | 16 | return $this->connections[$name] = $connection; |
|
| 34 | } |
||
| 35 | |||
| 45 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.