| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5.0187 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | 4 | public function getConnection() : Connection |
|
| 28 | { |
||
| 29 | 4 | if (! file_exists($this->filename)) { |
|
| 30 | 1 | throw FileNotFound::new($this->filename); |
|
| 31 | } |
||
| 32 | |||
| 33 | 3 | $params = include $this->filename; |
|
| 34 | |||
| 35 | 3 | if ($params instanceof Connection) { |
|
| 36 | 1 | return $params; |
|
| 37 | } |
||
| 38 | |||
| 39 | 2 | if ($params instanceof ConnectionLoader) { |
|
| 40 | return $params->getConnection(); |
||
| 41 | } |
||
| 42 | |||
| 43 | 2 | if (is_array($params)) { |
|
| 44 | 1 | return DriverManager::getConnection($params); |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | throw InvalidConfiguration::invalidArrayConfiguration(); |
|
| 48 | } |
||
| 49 | } |
||
| 50 |