File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed
Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 3535 },
3636
3737 "require-dev" : {
38- "jbzoo/toolbox-dev" : " ^2.6.2 " ,
38+ "jbzoo/toolbox-dev" : " ^2.8.0 " ,
3939 "jbzoo/data" : " ^4.1.3" ,
40- "symfony/process" : " ^5.2.3 " ,
41- "symfony/polyfill-mbstring" : " ^1.22.0 "
40+ "symfony/process" : " ^5.2.4 " ,
41+ "symfony/polyfill-mbstring" : " ^1.22.1 "
4242 },
4343
4444 "suggest" : {
Original file line number Diff line number Diff line change 2424 */
2525class Timer
2626{
27- /**
28- * @var array
29- */
30- private static $ times = [
31- 'hour ' => 3600000 ,
32- 'min ' => 60000 ,
33- 'sec ' => 1000 ,
34- ];
35-
3627 /**
3728 * Formats the elapsed time as a string.
3829 *
@@ -41,9 +32,15 @@ class Timer
4132 */
4233 public static function format (float $ milliSeconds ): string
4334 {
35+ $ times = [
36+ 'hour ' => 60 * 60 * 1000 ,
37+ 'min ' => 60 * 1000 ,
38+ 'sec ' => 1000 ,
39+ ];
40+
4441 $ time = round ($ milliSeconds * 1000 );
4542
46- foreach (self :: $ times as $ unit => $ value ) {
43+ foreach ($ times as $ unit => $ value ) {
4744 if ($ time >= $ value ) {
4845 $ time = floor ($ time / $ value * 100.0 ) / 100.0 ;
4946 return $ time . ' ' . $ unit . ($ time === 1.0 ? '' : 's ' );
You can’t perform that action at this time.
0 commit comments