<?php declare(strict_types=1);
class Spinner
{
public $speed = 100;
public static function create($speed)
{
}
}
Swoole\Runtime::enableCoroutine();
function spinner()
{
$chars = '-\|/';
$index = 0;
yield function () use ($chars, $index) {
while (1) {
printf("\x0D\x1B[2K %s handling ...", $chars[$index]);
if ($index+1 === mb_strlen($chars)) {
$index = 0;
} else {
$index++;
}
}
};
}
$y = spinner();sleep(4);
$y->send(false);