composer require aeon-php/sleep
This library provides literally one function that makes it easier to pause your process for a certain time.
Let say you would like to sleep for 200 milliseconds. Instead of using usleep and multiplication of 200 by... exactly, how much? Just use Aeon sleep.
<?php use Aeon\Calendar\TimeUnit; use function \Aeon\Sleep\sleep; sleep(TimeUnit::milliseconds(200));
Thanks to TimeUnit you can sleep with any precision you need.
Sleeping in tests might be tricky, one might put sleep in the test case but who likes slow test suite?
Instead of using function go with
SystemProcess and expect instance of
in your system under test.
<?php use Aeon\Calendar\System\SystemProcess; use Aeon\Calendar\TimeUnit; $process = SystemProcess::current(); $process->sleep(TimeUnit::milliseconds(200));