Conditions | 25 |
Paths | 52 |
Total Lines | 48 |
Code Lines | 42 |
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 |
||
16 | public function add($code, $symbol) |
||
17 | { |
||
18 | switch ($code) { |
||
19 | case T_WHITESPACE: |
||
|
|||
20 | $this->addType(self::T_WHITESPACE); |
||
21 | case T_NS_SEPARATOR: |
||
22 | $this->addType(self::T_CONTINUE_PROCESS); |
||
23 | break; |
||
24 | case T_STRING: |
||
25 | $this->addType(self::T_STRING); |
||
26 | $this->addType(self::T_CONTINUE_PROCESS); |
||
27 | break; |
||
28 | case T_VARIABLE: |
||
29 | case T_DOUBLE_COLON: |
||
30 | if ($this->isWhitespace()) { |
||
31 | $this->resetType(self::T_UNKNOWN); |
||
32 | break; |
||
33 | } |
||
34 | case T_OBJECT_OPERATOR: |
||
35 | if ($this->hasString() && $this->hasWhitespace()) { |
||
36 | $this->resetType(self::T_UNKNOWN); |
||
37 | break; |
||
38 | } |
||
39 | case T_NAMESPACE: |
||
40 | case T_USE: |
||
41 | case T_NEW: |
||
42 | case T_EXTENDS: |
||
43 | case T_IMPLEMENTS: |
||
44 | case '$': |
||
45 | case '(': |
||
46 | $this->resetType(self::$MAP[$code]); |
||
47 | break; |
||
48 | case ';': |
||
49 | case ',': |
||
50 | case '-': |
||
51 | case ':': |
||
52 | case '=': |
||
53 | case ')': |
||
54 | case ']': |
||
55 | $this->resetType(self::T_TERMINATE); |
||
56 | break; |
||
57 | default: |
||
58 | $this->addType(self::T_UNKNOWN); |
||
59 | } |
||
60 | if (!$this->isReady()) { |
||
61 | $this->symbol = $symbol . $this->symbol; |
||
62 | } |
||
63 | } |
||
64 | |||
213 |