Conditions | 5 |
Paths | 8 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
53 | 11 | public static function formatTime(float $time) : string |
|
54 | { |
||
55 | 11 | $time = $time < 1 ? 1 : round($time); |
|
56 | 11 | $formatted = []; |
|
57 | 11 | foreach (self::$times as $unit => $value) { |
|
58 | 11 | if ($time >= $value) { |
|
59 | 11 | $units = \floor($time / $value); |
|
60 | 11 | $time -= $units * $value; |
|
61 | 11 | $formatted[] = $units . ' ' . ($units == 1 ? $unit : $unit . 's'); |
|
62 | } |
||
63 | } |
||
64 | 11 | return implode(' ', $formatted); |
|
65 | } |
||
66 | } |
||
67 |