/** * Gets the required class refences from Phergie_Bot. * * @param Phergie_Bot $bot Current bot instance in use * @param array $options Optional processor arguments * * @return void */ public function __construct(Phergie_Bot $bot, array $options = array()) { $this->driver = $bot->getDriver(); $this->plugins = $bot->getPluginHandler(); $this->connections = $bot->getConnectionHandler(); $this->events = $bot->getEventHandler(); $this->ui = $bot->getUi(); $this->options = $options; }
/** * Overrides the parent class to set the poll time. * * @param Phergie_Bot $bot Main bot class * @param array $options Processor arguments * * @return void */ public function __construct(Phergie_Bot $bot, array $options) { if (!$bot->getDriver() instanceof Phergie_Driver_Streams) { throw new Phergie_Process_Exception('The Async event processor requires the Streams driver'); } foreach (array('sec', 'usec') as $var) { if (isset($options[$var])) { if (!is_int($options[$var])) { throw new Phergie_Process_Exception('Processor option "' . $var . '" must be an integer'); } $this->{$var} = $options[$var]; } } if (!isset($this->sec) && !isset($this->usec)) { throw new Phergie_Process_Exception('One of the processor options "sec" or "usec" must be specified'); } parent::__construct($bot, $options); }
/** * Tests that a custom driver can be used. * * @return void */ public function testSetDriver() { $driver = $this->getMockDriver(); $this->bot->setDriver($driver); $this->assertSame($driver, $this->bot->getDriver()); }