Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | 4 | public function __invoke() |
|
27 | { |
||
28 | 4 | $logicalConnection = $this->settings->tryGet(Doctrine1KnownSettingsEnum::LOGICAL_CONNECTION); |
|
29 | 4 | if ($logicalConnection) { |
|
30 | 1 | return $logicalConnection; |
|
31 | } |
||
32 | |||
33 | 3 | $dsn = $this->settings->tryGet(Doctrine1KnownSettingsEnum::DSN); |
|
34 | 3 | if (!$dsn) { |
|
35 | 1 | throw new UnexpectedValueException( |
|
36 | "The Doctrine 1 persistence requires a DSN. You can provide it through the persistence configurator." |
||
37 | 1 | ); |
|
38 | } |
||
39 | |||
40 | 2 | $manager = $this->settings->tryGet(Doctrine1KnownSettingsEnum::MANAGER); |
|
41 | 2 | if (!$manager) { |
|
42 | 1 | $manager = \Doctrine_Manager::getInstance(); |
|
43 | 1 | } |
|
44 | |||
45 | 2 | $connectionName = $this->settings->tryGet(Doctrine1KnownSettingsEnum::CONNECTION_NAME); |
|
46 | |||
47 | 2 | return new LogicalConnection($connectionName, $dsn, $manager); |
|
48 | } |
||
49 | } |
||
50 |