| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 3 | public function __invoke() |
|
| 31 | { |
||
| 32 | 3 | $connection = $this->settings->tryGet(Doctrine2KnownSettingsEnum::CONNECTION); |
|
| 33 | |||
| 34 | 3 | if ($connection) { |
|
| 35 | 1 | return $connection; |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | $connectionParameters = $this->settings->tryGet(Doctrine2KnownSettingsEnum::CONNECTION_PARAMETERS); |
|
| 39 | 2 | if (!$connectionParameters) { |
|
| 40 | 1 | throw new UnexpectedValueException( |
|
| 41 | "The Doctrine 2 persistence requires either a connection instance or connection parameters. " . |
||
| 42 | 1 | "You can provide them through the persistence configurator." |
|
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | 1 | return DriverManager::getConnection($connectionParameters); |
|
| 47 | } |
||
| 48 | } |
||
| 49 |