| Conditions | 11 |
| Paths | 81 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 15 |
| Ratio | 68.18 % |
| Tests | 0 |
| CRAP Score | 132 |
| 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 |
||
| 15 | public function secondsInStringTime($seconds) |
||
| 16 | { |
||
| 17 | View Code Duplication | if ($days = intval((floor($seconds / 86400)))) { |
|
| 18 | $seconds = $seconds - $days*86400; |
||
| 19 | $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
||
| 20 | } |
||
| 21 | View Code Duplication | if ($hours = intval((floor($seconds / 3600))) OR $return) { |
|
| 22 | $seconds = $seconds - $hours*3600; |
||
| 23 | $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
||
| 24 | } |
||
| 25 | View Code Duplication | if ($minutes = intval((floor($seconds / 60))) OR $return) { |
|
| 26 | $seconds = $seconds - $minutes*60; |
||
| 27 | $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
||
| 28 | } |
||
| 29 | |||
| 30 | $seconds = round($seconds, 2); |
||
| 31 | View Code Duplication | if ($seconds) { |
|
| 32 | $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT).'s'; |
||
| 33 | } |
||
| 34 | |||
| 35 | return $return; |
||
| 36 | } |
||
| 37 | |||
| 54 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.