getDriver() public method

Returns a driver instance, creating one of the default class if none has been set.
public getDriver ( ) : Phergie_Driver_Abstract
return Phergie_Driver_Abstract
Beispiel #1
0
 /**
  * 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;
 }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #3
0
 /**
  * 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());
 }