| Conditions | 12 | 
| Paths | 20 | 
| Total Lines | 25 | 
| 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  | 
            ||
| 47 | public function process(NodeInterface $node, $interceptorPosition, ParsingState $parsingState)  | 
            ||
| 48 |     { | 
            ||
| 49 | $viewHelper = $node instanceof ViewHelperNode ? $node->getUninitializedViewHelper() : $node;  | 
            ||
| 50 |         if ($interceptorPosition === InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER) { | 
            ||
| 51 | /** @var ViewHelperNode $node */  | 
            ||
| 52 |             if (!$viewHelper->isChildrenEscapingEnabled()) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 53 | $this->childrenEscapingEnabled = false;  | 
            ||
| 54 | $this->viewHelperNodesWhichDisableTheInterceptor[] = $node;  | 
            ||
| 55 | }  | 
            ||
| 56 |         } elseif ($interceptorPosition === InterceptorInterface::INTERCEPT_CLOSING_VIEWHELPER) { | 
            ||
| 57 |             if (end($this->viewHelperNodesWhichDisableTheInterceptor) === $node) { | 
            ||
| 58 | array_pop($this->viewHelperNodesWhichDisableTheInterceptor);  | 
            ||
| 59 |                 if (count($this->viewHelperNodesWhichDisableTheInterceptor) === 0) { | 
            ||
| 60 | $this->childrenEscapingEnabled = true;  | 
            ||
| 61 | }  | 
            ||
| 62 | }  | 
            ||
| 63 | /** @var ViewHelperNode $node */  | 
            ||
| 64 |             if ($this->childrenEscapingEnabled && $viewHelper->isOutputEscapingEnabled()) { | 
            ||
| 65 | $node = new EscapingNode($node);  | 
            ||
| 66 | }  | 
            ||
| 67 |         } elseif ($this->childrenEscapingEnabled && ($node instanceof ObjectAccessorNode || $node instanceof ExpressionNodeInterface)) { | 
            ||
| 68 | $node = new EscapingNode($node);  | 
            ||
| 69 | }  | 
            ||
| 70 | return $node;  | 
            ||
| 71 | }  | 
            ||
| 72 | |||
| 88 | 
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: