Interop\Async\Loop\DriverFactory::create PHP Method

create() public method

Create a new event loop driver instance.
public create ( ) : Driver
return Driver
    public function create();

Usage Example

Example #1
0
 /**
  * Create a new driver if a factory is present, otherwise throw.
  *
  * @return Driver
  *
  * @throws \Exception If no factory is set or no driver returned from factory.
  */
 private static function createDriver()
 {
     if (self::$factory === null) {
         throw new \Exception("No loop driver factory set; Either pass a driver to Loop::execute or set a factory.");
     }
     $driver = self::$factory->create();
     if (!$driver instanceof Driver) {
         $type = is_object($driver) ? "an instance of " . get_class($driver) : gettype($driver);
         throw new \Exception("Loop driver factory returned {$type}, but must return an instance of Driver.");
     }
     return $driver;
 }
DriverFactory