2020-07-21 18:06:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loop interface.
|
|
|
|
*
|
|
|
|
* @author Daniil Gentili <daniil@daniil.it>
|
|
|
|
* @copyright 2016-2020 Daniil Gentili <daniil@daniil.it>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT
|
|
|
|
*/
|
|
|
|
|
2020-07-21 21:45:22 +02:00
|
|
|
namespace danog\Loop\Interfaces;
|
2020-07-21 18:06:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loop interface.
|
|
|
|
*
|
|
|
|
* @author Daniil Gentili <daniil@daniil.it>
|
|
|
|
*/
|
|
|
|
interface LoopInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Start the loop.
|
2020-07-21 21:45:22 +02:00
|
|
|
*
|
2020-07-21 18:06:19 +02:00
|
|
|
* Returns false if the loop is already running.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function start(): bool;
|
|
|
|
/**
|
|
|
|
* The actual loop function.
|
|
|
|
*
|
|
|
|
* @return \Generator
|
|
|
|
*/
|
|
|
|
public function loop(): \Generator;
|
|
|
|
/**
|
|
|
|
* Get name of the loop.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function __toString(): string;
|
|
|
|
/**
|
|
|
|
* Check whether loop is running.
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isRunning(): bool;
|
|
|
|
}
|