| Conditions | 13 | 
| Paths | 39 | 
| Total Lines | 70 | 
| Code Lines | 40 | 
| Lines | 7 | 
| Ratio | 10 % | 
| 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  | 
            ||
| 43 | public function getAllClassNames()  | 
            ||
| 44 |     { | 
            ||
| 45 |         if ($this->classNames !== null) { | 
            ||
| 46 | return $this->classNames;  | 
            ||
| 47 | }  | 
            ||
| 48 | |||
| 49 |         if (!$this->paths) { | 
            ||
| 50 | throw MappingException::pathRequired();  | 
            ||
| 51 | }  | 
            ||
| 52 | |||
| 53 | $classes = [];  | 
            ||
| 54 | $includedFiles = [];  | 
            ||
| 55 | |||
| 56 |         foreach ($this->paths as $path) { | 
            ||
| 57 |             if ( ! is_dir($path)) { | 
            ||
| 58 | throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path);  | 
            ||
| 59 | }  | 
            ||
| 60 | |||
| 61 | $iterator = new \RegexIterator(  | 
            ||
| 62 | new \RecursiveIteratorIterator(  | 
            ||
| 63 | new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),  | 
            ||
| 64 | \RecursiveIteratorIterator::LEAVES_ONLY  | 
            ||
| 65 | ),  | 
            ||
| 66 | '/^.+' . preg_quote($this->fileExtension) . '$/i',  | 
            ||
| 67 | \RecursiveRegexIterator::GET_MATCH  | 
            ||
| 68 | );  | 
            ||
| 69 | |||
| 70 |             foreach ($iterator as $file) { | 
            ||
| 71 | $sourceFile = $file[0];  | 
            ||
| 72 | |||
| 73 |                 if ( ! preg_match('(^phar:)i', $sourceFile)) { | 
            ||
| 74 | $sourceFile = realpath($sourceFile);  | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 |                 foreach ($this->excludePaths as $excludePath) { | 
            ||
| 78 |                     $exclude = str_replace('\\', '/', realpath($excludePath)); | 
            ||
| 79 |                     $current = str_replace('\\', '/', $sourceFile); | 
            ||
| 80 | |||
| 81 |                     if (strpos($current, $exclude) !== false) { | 
            ||
| 82 | continue 2;  | 
            ||
| 83 | }  | 
            ||
| 84 | }  | 
            ||
| 85 | |||
| 86 | $proxyFile = str_replace($path, $this->trait_proxies_directory, $sourceFile);  | 
            ||
| 87 |                 if (file_exists($proxyFile)) { | 
            ||
| 88 | require_once $proxyFile;  | 
            ||
| 89 | |||
| 90 | $sourceFile = $proxyFile;  | 
            ||
| 91 |                 } else { | 
            ||
| 92 | require_once $sourceFile;  | 
            ||
| 93 | }  | 
            ||
| 94 | |||
| 95 | $includedFiles[] = $sourceFile;  | 
            ||
| 96 | }  | 
            ||
| 97 | }  | 
            ||
| 98 | |||
| 99 | $declared = get_declared_classes();  | 
            ||
| 100 | |||
| 101 | View Code Duplication |         foreach ($declared as $className) { | 
            |
| 102 | $rc = new \ReflectionClass($className);  | 
            ||
| 103 | $sourceFile = $rc->getFileName();  | 
            ||
| 104 |             if (in_array($sourceFile, $includedFiles) && ! $this->isTransient($className)) { | 
            ||
| 105 | $classes[] = $className;  | 
            ||
| 106 | }  | 
            ||
| 107 | }  | 
            ||
| 108 | |||
| 109 | $this->classNames = $classes;  | 
            ||
| 110 | |||
| 111 | return $classes;  | 
            ||
| 112 | }  | 
            ||
| 113 | }  |