1
0
mirror of https://github.com/danog/amp.git synced 2024-12-11 17:09:40 +01:00
amp/lib/Loop/DriverFactory.php
2017-03-14 22:33:45 +01:00

28 lines
557 B
PHP

<?php
namespace Amp\Loop;
// @codeCoverageIgnoreStart
class DriverFactory {
/**
* Creates a new loop instance and chooses the best available driver.
*
* @return Driver
*/
public function create(): Driver {
if (UvDriver::isSupported()) {
return new UvDriver;
}
if (EvDriver::isSupported()) {
return new EvDriver;
}
if (EventDriver::isSupported()) {
return new EventDriver;
}
return new NativeDriver;
}
}
// @codeCoverageIgnoreEnd