| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 56 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 33 | 
| CRAP Score | 1 | 
| 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 | ||
| 25 | 31 | public function __construct() | |
| 26 |     { | ||
| 27 | // General tokens | ||
| 28 | 31 |         $this->token('execution'); | |
| 29 | 31 |         $this->token('dynamic'); | |
| 30 | 31 |         $this->token('within'); | |
| 31 | 31 |         $this->token('access'); | |
| 32 | 31 |         $this->token('cflowbelow'); | |
| 33 | 31 |         $this->token('initialization'); | |
| 34 | 31 |         $this->token('staticinitialization'); | |
| 35 | 31 |         $this->token('matchInherited'); | |
| 36 | |||
| 37 | // Parenthesis | ||
| 38 | 31 |         $this->token('('); | |
| 39 | 31 |         $this->token(')'); | |
| 40 | |||
| 41 | // Member modifiers | ||
| 42 | 31 |         $this->token('public'); | |
| 43 | 31 |         $this->token('protected'); | |
| 44 | 31 |         $this->token('private'); | |
| 45 | 31 |         $this->token('final'); | |
| 46 | |||
| 47 | // Access type (dynamic or static) | ||
| 48 | 31 |         $this->token('->'); | |
| 49 | 31 |         $this->token('::'); | |
| 50 | |||
| 51 | // Logic tokens | ||
| 52 | 31 |         $this->token('!'); | |
| 53 | 31 |         $this->token('&'); | |
| 54 | 31 |         $this->token('&&'); | |
| 55 | 31 |         $this->token('|'); | |
| 56 | 31 |         $this->token('||'); | |
| 57 | |||
| 58 | 31 |         $this->token('annotation', '@'); | |
| 59 | |||
| 60 | // Regex for class name | ||
| 61 | 31 |         $this->regex('namePart', '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/'); | |
| 62 | |||
| 63 | // NS separator | ||
| 64 | 31 |         $this->token('nsSeparator', '\\'); | |
| 65 | |||
| 66 | // Return-type specifier | ||
| 67 | 31 |         $this->token(':'); | |
| 68 | |||
| 69 | // Special wildcard tokens | ||
| 70 | 31 |         $this->token('+'); | |
| 71 | 31 |         $this->token('*'); | |
| 72 | 31 |         $this->token('**'); | |
| 73 | |||
| 74 | // White spaces | ||
| 75 | 31 |         $this->regex('WSP', "/^[ \r\n\t]+/"); | |
| 76 | |||
| 77 | // Comments | ||
| 78 | 31 |         $this->regex('CMT', '|^//.*|'); | |
| 79 | 31 |         $this->skip('CMT', 'WSP'); | |
| 80 | 31 | } | |
| 81 | } | ||
| 82 |