Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.0218 |
Changes | 0 |
1 | <?php |
||
23 | 35 | public function chosen() |
|
24 | { |
||
25 | 35 | if (empty($this->filename)) { |
|
26 | 34 | return null; |
|
27 | } |
||
28 | |||
29 | 35 | if ( ! file_exists($this->filename)) { |
|
30 | 34 | return null; |
|
31 | } |
||
32 | |||
33 | 1 | $params = include $this->filename; |
|
34 | 1 | if ( ! is_array($params)) { |
|
35 | throw new \InvalidArgumentException('The connection file has to return an array with database configuration parameters.'); |
||
36 | } |
||
37 | |||
38 | 1 | return DriverManager::getConnection($params); |
|
39 | } |
||
40 | } |
||
41 |