| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 41 | public static function guessNamespace($dir) |
||
| 42 | { |
||
| 43 | if (!defined('APP_PATH')) { |
||
| 44 | return; |
||
| 45 | } |
||
| 46 | |||
| 47 | $config = Config::getInstance(); |
||
| 48 | |||
| 49 | $method = 'get'.ucfirst($dir).'Directory'; |
||
| 50 | |||
| 51 | $path = Config::getInstance()->$method(); |
||
| 52 | |||
| 53 | $appPathArray = explode('/', APP_PATH); |
||
| 54 | |||
| 55 | $relativePath = array_diff(explode('/', $path), $appPathArray); |
||
| 56 | |||
| 57 | if (($root = $config->get(['namespaces', 'root'])) !== null) { |
||
| 58 | array_unshift($relativePath, $root); |
||
| 59 | } else { |
||
| 60 | array_unshift($relativePath, array_pop($appPathArray)); |
||
| 61 | } |
||
| 62 | |||
| 63 | return implode('\\', array_map('ucfirst', $relativePath)); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |