Phergie\Irc\Client\React\Client::addTimer PHP Method

addTimer() public method

Adds a one-time callback to execute after a specified amount of time has passed. Proxies to addTimer() implementation of the event loop implementation returned by getLoop().
public addTimer ( numeric $interval, callable $callback ) : React\Event\Timer\TimerInterface
$interval numeric Number of seconds to wait before executing callback
$callback callable Callback to execute
return React\Event\Timer\TimerInterface Added timer
    public function addTimer($interval, $callback)
    {
        return $this->getLoop()->addTimer($interval, $callback);
    }

Usage Example

 /**
  * Tests addTimer().
  */
 public function testAddTimer()
 {
     $interval = 5;
     $callback = function () {
     };
     $timer = $this->getMockTimer();
     $loop = $this->getMockLoop();
     Phake::when($loop)->addTimer($interval, $callback)->thenReturn($timer);
     Phake::when($this->client)->getLoop()->thenReturn($loop);
     $this->assertSame($timer, $this->client->addTimer($interval, $callback));
 }