Conditions | 4 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | public static function getClassesInNamespace(string $className): array |
||
37 | { |
||
38 | $result = []; |
||
39 | $loader = include Craft::getAlias('@vendor/autoload.php'); |
||
40 | $filePath = $loader->findFile($className); |
||
41 | if ($filePath) { |
||
42 | $dir = realpath(dirname($filePath)); |
||
43 | $classesMap = ClassMapGenerator::createMap($dir); |
||
44 | foreach ($classesMap as $class => $path) { |
||
45 | try { |
||
46 | $reflect = new ReflectionClass($class); |
||
47 | $shortName = $reflect->getShortName(); |
||
48 | $result[$shortName] = $class; |
||
49 | } catch (ReflectionException $e) { |
||
50 | Craft::error($e->getMessage(), __METHOD__); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | ksort($result); |
||
55 | |||
56 | return $result; |
||
57 | } |
||
59 |