| Total Complexity | 8 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Resolver |
||
| 6 | { |
||
| 7 | private $namespace_cascade = []; |
||
| 8 | private $resolved_cache = []; |
||
| 9 | |||
| 10 | public function __construct($namespace_cascade = []){ |
||
| 11 | $this->namespace_cascade = $namespace_cascade; |
||
| 12 | } |
||
| 13 | |||
| 14 | public function cascadeNamespace($class_name) |
||
| 15 | { |
||
| 16 | if ($this->isResolved($class_name)) { |
||
| 17 | return $this->resolved($class_name); |
||
| 18 | } |
||
| 19 | |||
| 20 | // not fully namespaced, lets cascade |
||
| 21 | foreach ($this->namespace_cascade as $ns) { |
||
| 22 | if (class_exists($fully_namespaced = $ns . $class_name)) { |
||
| 23 | $this->resolved($class_name, $fully_namespaced); |
||
| 24 | return $fully_namespaced; |
||
| 25 | } |
||
| 26 | } |
||
| 27 | throw new NotFoundException($class_name); |
||
| 28 | } |
||
| 29 | |||
| 30 | |||
| 31 | public function resolved($clue, $solution = null) |
||
| 38 | } |
||
| 39 | |||
| 40 | public function isResolved($clue): bool |
||
| 43 | } |
||
| 44 | } |
||
| 45 |