| Conditions | 12 |
| Paths | 42 |
| Total Lines | 34 |
| Code Lines | 22 |
| 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 |
||
| 129 | public static function inInterval($minStrTime, $maxStrTime, $checkStrTime = '') { |
||
| 130 | |||
| 131 | $minTime = new self($minStrTime); |
||
| 132 | if($maxStrTime == '00:00') { |
||
| 133 | $maxStrTime = '23:59'; |
||
| 134 | } |
||
| 135 | $maxTime = new self($maxStrTime); |
||
| 136 | $checkTime = new self($checkStrTime); |
||
| 137 | |||
| 138 | if($minTime->getHours() == $checkTime->getHours()) { |
||
| 139 | if($minTime->getMinutes() == $checkTime->getMinutes()) { |
||
| 140 | if($minTime->getSeconds() > $checkTime->getSeconds()) { |
||
| 141 | return false; |
||
| 142 | } |
||
| 143 | } else if($minTime->getMinutes() > $checkTime->getMinutes()) { |
||
| 144 | return false; |
||
| 145 | } |
||
| 146 | } else if($minTime->getHours() > $checkTime->getHours()) { |
||
| 147 | return false; |
||
| 148 | } |
||
| 149 | |||
| 150 | if($maxTime->getHours() == $checkTime->getHours()) { |
||
| 151 | if($maxTime->getMinutes() == $checkTime->getMinutes()) { |
||
| 152 | if($minTime->getSeconds() < $checkTime->getSeconds()) { |
||
| 153 | return false; |
||
| 154 | } |
||
| 155 | } else if($maxTime->getMinutes() < $checkTime->getMinutes()) { |
||
| 156 | return false; |
||
| 157 | } |
||
| 158 | } else if($maxTime->getHours() < $checkTime->getHours()) { |
||
| 159 | return false; |
||
| 160 | } |
||
| 161 | |||
| 162 | return true; |
||
| 163 | } |
||
| 164 | } |