Conditions | 14 |
Paths | 26 |
Total Lines | 57 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
49 | public function compare(\DateInterval $first, \DateInterval $second) |
||
50 | { |
||
51 | if ($this->safe) { |
||
52 | $this->safecheck($first); |
||
53 | $this->safecheck($second); |
||
54 | } |
||
55 | |||
56 | if ($first->y > $second->y) { |
||
57 | return 1; |
||
58 | } |
||
59 | |||
60 | if ($first->y < $second->y) { |
||
61 | return -1; |
||
62 | } |
||
63 | |||
64 | if ($first->m > $second->m) { |
||
65 | return 1; |
||
66 | } |
||
67 | |||
68 | if ($first->m < $second->m) { |
||
69 | return -1; |
||
70 | } |
||
71 | |||
72 | if ($first->d > $second->d) { |
||
73 | return 1; |
||
74 | } |
||
75 | |||
76 | if ($first->d < $second->d) { |
||
77 | return -1; |
||
78 | } |
||
79 | |||
80 | if ($first->h > $second->h) { |
||
81 | return 1; |
||
82 | } |
||
83 | |||
84 | if ($first->h < $second->h) { |
||
85 | return -1; |
||
86 | } |
||
87 | |||
88 | if ($first->i > $second->i) { |
||
89 | return 1; |
||
90 | } |
||
91 | |||
92 | if ($first->i < $second->i) { |
||
93 | return -1; |
||
94 | } |
||
95 | |||
96 | if ($first->s > $second->s) { |
||
97 | return 1; |
||
98 | } |
||
99 | |||
100 | if ($first->s < $second->s) { |
||
101 | return -1; |
||
102 | } |
||
103 | |||
104 | return 0; |
||
105 | } |
||
106 | |||
131 |