| Total Complexity | 3 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | trait ResolvesClasses |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Resolves and Initializes Class by filename. |
||
| 12 | * |
||
| 13 | * @param SplFileInfo $fileInfo |
||
| 14 | * @param null|Closure $callback |
||
| 15 | */ |
||
| 16 | public function resolveClass(SplFileInfo $fileInfo, Closure $callback = null) |
||
| 17 | { |
||
| 18 | /** @noinspection PhpIncludeInspection */ |
||
| 19 | require_once $fileInfo->getPathname(); |
||
| 20 | |||
| 21 | $instance = app()->make($this->getModuleClassName($fileInfo)); |
||
|
|
|||
| 22 | |||
| 23 | if (\is_callable($callback)) { |
||
| 24 | $callback($instance); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param SplFileInfo $fileInfo |
||
| 30 | * |
||
| 31 | * @return mixed |
||
| 32 | */ |
||
| 33 | protected function getModuleClassName(SplFileInfo $fileInfo) |
||
| 46 | } |
||
| 47 | } |
||
| 48 |