Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
16 | public function resolve(string $className): RepositoryInterface |
||
17 | { |
||
18 | if (!class_exists($className)) { |
||
19 | $exception = new CouldNotResolve("Class " . $className . " doesn't exist"); |
||
20 | $exception->setRepositoryCode($className); |
||
21 | |||
22 | throw $exception; |
||
23 | } |
||
24 | |||
25 | if (in_array(Model::class, class_implements($className))) { |
||
26 | $exception = new CouldNotResolve("The passed argument must be an instance of " . Model::class); |
||
27 | $exception->setRepositoryCode($className); |
||
28 | |||
29 | throw $exception; |
||
30 | } |
||
31 | |||
32 | return new EloquentRepository($className); |
||
33 | } |
||
35 |