1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 21:31:18 +01:00
amp/lib/ReactorFactory.php

28 lines
472 B
PHP
Raw Normal View History

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;
}
}