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