1
0
mirror of https://github.com/danog/amp.git synced 2024-12-04 02:17:54 +01:00

Check that factory returns an instance of LoopDriver

This commit is contained in:
Niklas Keller 2016-05-15 20:18:45 +02:00
parent 30254b2a36
commit f66cb4a66f

View File

@ -54,7 +54,7 @@ final class Loop
/** /**
* Create a new driver if a factory is present, otherwise throw. * Create a new driver if a factory is present, otherwise throw.
* *
* @throws \LogicException if no factory is set * @throws \LogicException if no factory is set or no driver returned from factory
*/ */
private static function createDriver() private static function createDriver()
{ {
@ -62,7 +62,13 @@ final class Loop
throw new \LogicException("Can't create an event loop driver without a factory."); throw new \LogicException("Can't create an event loop driver without a factory.");
} }
return self::$factory->create(); $driver = self::$factory->create();
if (!$driver instanceof LoopDriver) {
throw new \LogicException("LoopDriverFactory didn't return a LoopDriver.");
}
return $driver;
} }
/** /**