| Conditions | 14 | 
| Paths | 12 | 
| Total Lines | 25 | 
| Code Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
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 | ||
| 36 | public function enterNode(Node $node) | ||
| 37 |     { | ||
| 38 | $this->prepareUseClasses($node); | ||
| 39 | // find new Class(arg1, arg2, arg3) | ||
| 40 |         if ($node instanceof New_ && isset($node->class) && in_array($node->class->name ?? null, $this->classArgposClassesMap, true)) { | ||
|  | |||
| 41 | $className = $node->class->name; | ||
| 42 | $argIndex = array_search($className, $this->classArgposClassesMap); | ||
| 43 | $args = $node->args; | ||
| 44 |             if (isset($args[$argIndex]) && $args[$argIndex]->value instanceof String_) { | ||
| 45 | $key = $args[$argIndex]->value->value; | ||
| 46 | $this->addKey($args[$argIndex]->getStartLine(), $className, $key); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | // find in Class ->method(arg1, arg2, arg3) | ||
| 50 | if ($node instanceof MethodCall && | ||
| 51 |             $node->name instanceof Identifier) { | ||
| 52 | $methodName = $node->name->name; | ||
| 53 |             foreach ($this->config['CLASS_ARGPOS_METHODS'] ?? [] as $classNamePart => $argposMethods) { | ||
| 54 | // ALL classes OR Classes end with classNamePart | ||
| 55 |                 if ($classNamePart !== 'ALL' && (strpos($this->className, $classNamePart) === false || substr($this->className, -strlen($classNamePart)) !== $classNamePart)) { | ||
| 56 | continue; | ||
| 57 | } | ||
| 58 |                 foreach ($argposMethods as $argIndex => $methods) { | ||
| 59 |                     if (in_array($methodName, $methods, true)) { | ||
| 60 | $this->extractKeyFromArgument($node, $argIndex, $classNamePart); | ||
| 61 | } | ||
| 137 |