Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 3 | public function resolve(string $className): RepositoryInterface |
|
16 | { |
||
17 | 3 | if (class_exists($className)) { |
|
18 | 2 | $model = new $className(); |
|
19 | 2 | if ($model instanceof HasRepositoryInterface) { |
|
20 | 1 | return $model->getRepository(); |
|
21 | } |
||
22 | } |
||
23 | |||
24 | 2 | $exception = new CouldNotResolve(); |
|
25 | 2 | $exception->setRepositoryCode($className); |
|
26 | |||
27 | 2 | throw $exception; |
|
28 | } |
||
30 |