| Conditions | 12 |
| Paths | 12 |
| Total Lines | 28 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 30 | public function setToken(Token $token) { |
||
| 31 | $this->token = $token; |
||
| 32 | if ($token->isVar()) { |
||
| 33 | $this->addType(Context::T_VAR); |
||
| 34 | } elseif ($token->isObjectOperator()) { |
||
| 35 | $this->addType(Context::T_OBJECT); |
||
| 36 | } elseif ($token->isStaticOperator()) { |
||
| 37 | $this->addType(Context::T_CLASS_STATIC); |
||
| 38 | } elseif ($token->isNamespaceOperator()) { |
||
| 39 | $this->addType(Context::T_NAMESPACE); |
||
| 40 | } elseif ($token->isUseOperator()) { |
||
| 41 | $this->addType(Context::T_USE); |
||
| 42 | $this->addType(Context::T_CLASSNAME); |
||
| 43 | } elseif ($token->isNewOperator()) { |
||
| 44 | $this->addType(Context::T_CLASSNAME); |
||
| 45 | } elseif ($token->isExtendsOperator()) { |
||
| 46 | $this->addType(Context::T_CLASSNAME); |
||
| 47 | } elseif ($token->isImplementsOperator()) { |
||
| 48 | $this->addType(Context::T_INTERFACENAME); |
||
| 49 | } elseif ($token->isMethodCall()) { |
||
| 50 | $this->addType(Context::T_METHOD_CALL); |
||
| 51 | } elseif ($token->isString()) { |
||
| 52 | $this->addType(self::T_ANY_NAME); |
||
| 53 | $this->setData($token->getSymbol()); |
||
| 54 | } elseif ($token->isTerminate()) { |
||
| 55 | $this->setData($token->getSymbol()); |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 122 |