Skip to content

Commit

Permalink
Merge pull request #57 from Korbeil/feature/php-8.1-deprecations
Browse files Browse the repository at this point in the history
Fix floating deprecations with % operator
  • Loading branch information
lyrixx authored Aug 24, 2022
2 parents 363bf7d + 5dad7ba commit 406eb5e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Output/PhpUnitAlike.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,31 @@ private function getDisplayableMemory($memory)
return @round($memory / pow(1000, ($i = floor(log($memory, 1000)))), 2).(isset($unit[$i]) ? $unit[$i] : 'B');
}

private function getDisplayableTime($time)
private function getDisplayableTime(float $time): string
{
$milliseconds = $time;
$seconds = round(($time % 60000) / 1000, 2);
$minutes = round(($time / (1000 * 60)) % 60);
$hours = round($time / (1000 * 60 * 60));
$seconds = (intval($time) % 60000) / 1000;
$minutes = intval($time / (1000 * 60)) % 60;
$hours = $time / (1000 * 60 * 60);

$text = $milliseconds.' milliseconds';
$text = sprintf('%.2F milliseconds', $milliseconds);

if (($seconds - 0.1) < 0) {
return $text;
}

$text = $seconds.' seconds';
$text = sprintf('%.2F seconds', $seconds);

if (($minutes - 0.1) < 0) {
return $text;
}

$text = $minutes.' minutes, '.$text;
$text = sprintf('%d minutes, %s', $minutes, $text);

if (($hours - 0.1) < 0) {
return $text;
}

return $hours.' hours, '.$text;
return sprintf('%d hours, %s', $hours, $text);
}
}

0 comments on commit 406eb5e

Please sign in to comment.