2013-08-05 16:05:08 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Alert;
|
|
|
|
|
|
|
|
class ReactorFactory {
|
|
|
|
|
|
|
|
private $hasExtLibevent;
|
|
|
|
|
2014-02-23 16:26:28 -05:00
|
|
|
public function __construct() {
|
2013-08-05 16:05:08 -04:00
|
|
|
$this->hasExtLibevent = extension_loaded('libevent');
|
|
|
|
}
|
|
|
|
|
2014-02-23 16:26:28 -05:00
|
|
|
public function __invoke() {
|
2013-08-05 16:05:08 -04:00
|
|
|
return $this->select();
|
|
|
|
}
|
|
|
|
|
2014-02-23 16:26:28 -05:00
|
|
|
public function select() {
|
2013-08-05 16:05:08 -04:00
|
|
|
if ($this->hasExtLibevent) {
|
|
|
|
$reactor = new LibeventReactor;
|
|
|
|
} else {
|
|
|
|
$reactor = new NativeReactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $reactor;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|