| Conditions | 14 | 
| Paths | 33 | 
| Total Lines | 44 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 28 | 
| CRAP Score | 14 | 
| 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  | 
            ||
| 12 | 4 | public function run(Filesystem $fs)  | 
            |
| 13 |     { | 
            ||
| 14 | 4 | $routes = [];  | 
            |
| 15 | 4 |         foreach ($fs->listClasses('Controller') as $class) { | 
            |
| 16 | 4 | $nick = substr(strtolower($class), 11);  | 
            |
| 17 | 4 | $reflectionClass =new ReflectionClass($class);  | 
            |
| 18 | 4 | $traits = $reflectionClass->getTraits();  | 
            |
| 19 | 4 | $ignore = [];  | 
            |
| 20 | 4 |             if (count($traits)) { | 
            |
| 21 | 4 |                 foreach ($traits as $trait) { | 
            |
| 22 | 4 |                     foreach ($trait->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { | 
            |
| 23 | 4 |                         if ($method->isConstructor() || $method->getName() == '__debugInfo') { | 
            |
| 24 | 4 | continue;  | 
            |
| 25 | }  | 
            ||
| 26 | 4 | $ignore[] = $method->getName();  | 
            |
| 27 | }  | 
            ||
| 28 | }  | 
            ||
| 29 | }  | 
            ||
| 30 | 4 | $methods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC);  | 
            |
| 31 | 4 |             foreach ($methods as $method) { | 
            |
| 32 | 4 |                 if ($method->isConstructor() || $method->getName() == '__debugInfo') { | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 33 | 4 | continue;  | 
            |
| 34 | }  | 
            ||
| 35 | 4 |                 if (in_array($method->name, $ignore)) { | 
            |
| 36 | 4 | continue;  | 
            |
| 37 | }  | 
            ||
| 38 | 4 |                 if ($method->name == '__process') { | 
            |
| 39 | 4 | $routes[] = $nick.'/*';  | 
            |
| 40 |                 } else { | 
            ||
| 41 | 4 | $routes[] = $nick.'/'.$method->name;  | 
            |
| 42 | }  | 
            ||
| 43 | }  | 
            ||
| 44 | }  | 
            ||
| 45 | |||
| 46 | 4 | $jobs = [];  | 
            |
| 47 | 4 |         foreach ($fs->listClasses('Job') as $class) { | 
            |
| 48 | 4 | $reflection = new ReflectionClass($class);  | 
            |
| 49 | 4 |             if (!$reflection->isAbstract()) { | 
            |
| 50 | 4 |                 $jobs[] = str_replace('\\', '.', substr(strtolower($class), 4)); | 
            |
| 51 | }  | 
            ||
| 52 | }  | 
            ||
| 53 | |||
| 54 | 4 |         return compact('routes', 'jobs'); | 
            |
| 55 | }  | 
            ||
| 56 | }  | 
            ||
| 57 |