Files
kiri-http-server/Abstracts/DoWhile.php
T

37 lines
432 B
PHP
Raw Normal View History

2022-06-16 17:38:22 +08:00
<?php
namespace Kiri\Server\Abstracts;
2022-12-12 17:31:11 +08:00
use Kiri\Di\Context;
2022-06-16 17:38:22 +08:00
class DoWhile
{
private bool $isStop = false;
/**
* @param array|\Closure $handler
* @return void
*/
public static function waite(array|\Closure $handler): void
{
2023-04-03 11:08:10 +08:00
if (Context::exists('stop')) {
2022-06-16 17:38:22 +08:00
return;
}
$handler();
self::waite($handler);
}
/**
* @return void
*/
public static function stop(): void
{
2023-04-03 11:08:10 +08:00
Context::set('stop', 1);
2022-06-16 17:38:22 +08:00
}
}