| Conditions | 5 |
| Paths | 5 |
| Total Lines | 34 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public static function map($path, $namespace) |
||
| 14 | { |
||
| 15 | $reader = new AnnotationReader(); |
||
| 16 | $mapping = []; |
||
| 17 | |||
| 18 | $directory = new RecursiveDirectoryIterator($path); |
||
| 19 | $directory = new RecursiveIteratorIterator($directory); |
||
| 20 | |||
| 21 | foreach ($directory as $node) { |
||
| 22 | if (!is_file($node->getPathname())) { |
||
| 23 | continue; |
||
| 24 | } |
||
| 25 | |||
| 26 | $file = substr($node->getPathname(), strlen($path)); |
||
| 27 | $file = ltrim($file, DIRECTORY_SEPARATOR); |
||
| 28 | $file = rtrim($file, '.php'); |
||
| 29 | |||
| 30 | $class = $namespace . '\\' . str_replace(DIRECTORY_SEPARATOR, '\\', $file); |
||
| 31 | |||
| 32 | if (!class_exists($class)) { |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | $annotation = $reader->getClassAnnotation(new ReflectionClass($class), Handler::class); |
||
| 37 | |||
| 38 | if (!($annotation instanceof Handler)) { |
||
| 39 | continue; |
||
| 40 | } |
||
| 41 | |||
| 42 | $mapping[$class] = $annotation->getHandler(); |
||
| 43 | } |
||
| 44 | |||
| 45 | return $mapping; |
||
| 46 | } |
||
| 47 | |||
| 59 |