Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\TimerInterface Interface Reference

Interface for a timer implementation. More...

+ Inheritance diagram for Erebot\TimerInterface:

Public Member Functions

 activate ()
 
 getArgs ()
 
 getCallback ()
 
 getDelay ()
 
 getRepetition ()
 
 getStream ()
 
 reset ()
 
 setArgs (array $args)
 
 setCallback (\Erebot\CallableInterface $callback)
 
 setRepetition ($repeat)
 

Detailed Description

Interface for a timer implementation.

This interface provides the necessary methods to implement timers and make them available to other parts of the bot.

Definition at line 31 of file TimerInterface.php.

Member Function Documentation

Erebot\TimerInterface::activate ( )

Calls the callback.

Warning
This method is called automatically and should not be called manually. Calling it manually may lead to unexpected results.

Implemented in Erebot\Timer.

Erebot\TimerInterface::getArgs ( )

Returns an array of additional arguments to pass to the callback.

Return values
arrayArguments that will be passed to the callback.
Note
The first argument passed to the callback is ALWAYS the timer event that timed out, but the timer IS NOT considered as a part of the arguments for the purpose of this method and therefore will be missing from the array it returns.

Implemented in Erebot\Timer.

Erebot\TimerInterface::getCallback ( )

Returns a reference to the callback associated with this timer.

Return values
callbackThe callback for this timer.

Implemented in Erebot\Timer.

Erebot\TimerInterface::getDelay ( )

Returns the delay after which the callback will be called. This is the original value given to the timer during construction, and it is not updated live as time passes by.

Return values
numberThe original delay for this timer, as decided at construction time.

Implemented in Erebot\Timer.

Erebot\TimerInterface::getRepetition ( )

Returns the number of timer this timer will be restarted.

Return values
intReturns the repetition state of the timer.

Implemented in Erebot\Timer.

Erebot\TimerInterface::getStream ( )

Returns the underlying stream used by the implementation to create timers.

Return values
streamThe underlying PHP stream.

Implemented in Erebot\Timer.

Erebot\TimerInterface::reset ( )

(Re)starts the timer.

Postcondition
The timer is started. The repetition counter is decremented as necessary.
Warning
It is the responsability of whoever uses the timer to restart it when needed.

Implemented in Erebot\Timer.

Erebot\TimerInterface::setArgs ( array  $args)

Sets the arguments for this timer.

Whenever this timer fires, its callback will be called with these arguments.

Parameters
array$argsAn array containing the parameters to pass to this timer's callback whenever it fires. The parameters will be passed in the same order they appear in this array.

Implemented in Erebot\Timer.

Erebot\TimerInterface::setCallback ( \Erebot\CallableInterface  $callback)

Sets the callback associated with this timer.

Parameters
Erebot::CallableInterface$callbackThis callable object will be called whenever the timer fires.

Implemented in Erebot\Timer.

Erebot\TimerInterface::setRepetition (   $repeat)

Changes the number of times this timer can go off.

Parameters
bool | int$repeatCan be either:
  • An integer indicating the number of times the timer will be triggered (with any negative value being treated as positive infinity).
  • A boolean which indicates that the timer should call the callback repeatedly (true, same as -1) or just once (false, same as 1).

Implemented in Erebot\Timer.


The documentation for this interface was generated from the following file: