diff --git a/src/TerminalObject/Helper/Sleeper.php b/src/TerminalObject/Helper/Sleeper.php index b0ae6398..c94d8a56 100644 --- a/src/TerminalObject/Helper/Sleeper.php +++ b/src/TerminalObject/Helper/Sleeper.php @@ -7,7 +7,7 @@ class Sleeper implements SleeperInterface /** * The default length of the sleep * - * @var int|float $speed + * @var int $speed */ protected $speed = 50000; @@ -16,12 +16,12 @@ class Sleeper implements SleeperInterface * * @param int|float $percentage * - * @return float + * @return int */ public function speed($percentage) { if (is_numeric($percentage) && $percentage > 0) { - $this->speed *= (100 / $percentage); + $this->speed = (int) round($this->speed * (100 / $percentage)); } return $this->speed; diff --git a/tests/SleeperTest.php b/tests/SleeperTest.php index ad9d461a..8b2525e5 100644 --- a/tests/SleeperTest.php +++ b/tests/SleeperTest.php @@ -58,4 +58,16 @@ public function it_will_ignore_zero_percentages() $sleeper->sleep(); } + + + /** + * @test + */ + public function it_uses_whole_integers_only() + { + $sleeper = new Sleeper(); + + $result = $sleeper->speed(33); + self::assertSame(151515, $result); + } }