1
0
mirror of https://github.com/danog/amp.git synced 2024-12-14 18:37:30 +01:00
amp/lib/ReactorFactory.php

28 lines
472 B
PHP
Raw Normal View History

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