Conditions | 10 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
51 | protected static function createClassMap($dir): array |
||
52 | { |
||
53 | if (\is_string($dir)) { |
||
54 | $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)); |
||
55 | } |
||
56 | $map = []; |
||
57 | |||
58 | if(\is_array($dir) || $dir instanceof \Traversable){ |
||
|
|||
59 | foreach ($dir as $file) { |
||
60 | if (!$file->isFile()) { |
||
61 | continue; |
||
62 | } |
||
63 | $path = $file->getRealPath() ?: $file->getPathname(); |
||
64 | if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) { |
||
65 | continue; |
||
66 | } |
||
67 | $classes = self::findClasses($path); |
||
68 | if (\PHP_VERSION_ID >= 70000) { |
||
69 | // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 |
||
70 | gc_mem_caches(); |
||
71 | } |
||
72 | foreach ($classes as $class) { |
||
73 | $map[ $class ] = $path; |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | |||
78 | return $map; |
||
79 | } |
||
150 | } |