1
0
mirror of https://github.com/danog/loop.git synced 2024-12-11 16:59:46 +01:00
loop/test/Traits/Resumable.php

39 lines
754 B
PHP
Raw Normal View History

2022-12-24 14:36:39 +01:00
<?php declare(strict_types=1);
2020-07-21 18:06:19 +02:00
/**
* Resumable test trait.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2020 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/MIT MIT
*/
namespace danog\Loop\Test\Traits;
2020-07-21 21:45:22 +02:00
trait Resumable
2020-07-21 18:06:19 +02:00
{
use Basic;
2020-07-21 19:12:11 +02:00
/**
* Set interval.
*/
2022-12-24 15:03:00 +01:00
protected ?int $interval = 100;
2020-07-21 19:12:11 +02:00
/**
* Set sleep interval.
*
* @param ?int $interval Interval
*
*/
2020-07-22 18:18:57 +02:00
public function setInterval(?int $interval): void
2020-07-21 19:12:11 +02:00
{
$this->interval = $interval;
}
2020-07-21 18:06:19 +02:00
/**
* Loop implementation.
*/
2022-12-24 15:03:00 +01:00
public function loop(): void
2020-07-21 18:06:19 +02:00
{
2020-07-21 19:12:11 +02:00
$this->inited = true;
2022-12-23 20:45:00 +01:00
$this->pause($this->interval);
2020-07-21 18:06:19 +02:00
$this->ran = true;
}
}