<?php
/**
* TEST: Timer periodic switch test.
*/
declare(strict_types=1);
use Tester\Assert;
require(__DIR__ . '/../bootstrap.php');
$loop = React\EventLoop\Factory::create();
$count = 0;
$timer = new Awaited\Timer($loop, 0.1, false, function(Awaited\Timer $timer) use(&$count): void {
$timer->setPeriodic(true);
$count++;
if ($count === 2) {
$timer->setPeriodic(false);
}
}, true);
$loop->run();
Assert::same(2, $count);