Skip to content

Commit

Permalink
feat(Sleep): usleep extract to method
Browse files Browse the repository at this point in the history
  • Loading branch information
h4kuna committed Jun 7, 2024
1 parent 0d0ed97 commit 10df529
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Date/Sleep.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class Sleep
*/
public static function seconds(float $duration): void
{
usleep((int) ($duration * 1_000_000.0));
self::usleep((int) ($duration * 1_000_000.0));
}


Expand All @@ -18,7 +18,14 @@ public static function seconds(float $duration): void
*/
public static function milliseconds(int $duration): void
{
self::seconds($duration / 1_000.0);
self::usleep($duration * 1_000);
}


private static function usleep(int $microseconds): void
{
if ($microseconds > 0) {
usleep($microseconds);
}
}
}

0 comments on commit 10df529

Please sign in to comment.