mirror of
https://github.com/danog/amp.git
synced 2024-12-14 18:37:30 +01:00
28 lines
451 B
PHP
28 lines
451 B
PHP
<?php
|
|
|
|
namespace Alert;
|
|
|
|
class ReactorFactory {
|
|
|
|
private $hasExtLibevent;
|
|
|
|
function __construct() {
|
|
$this->hasExtLibevent = extension_loaded('libevent');
|
|
}
|
|
|
|
function __invoke() {
|
|
return $this->select();
|
|
}
|
|
|
|
function select() {
|
|
if ($this->hasExtLibevent) {
|
|
$reactor = new LibeventReactor;
|
|
} else {
|
|
$reactor = new NativeReactor;
|
|
}
|
|
|
|
return $reactor;
|
|
}
|
|
|
|
}
|