File tree 3 files changed +20
-2
lines changed
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,14 @@ class EioDriver implements Driver
11
11
/** @var \Amp\File\Internal\EioPoll */
12
12
private $ poll ;
13
13
14
+ /**
15
+ * @return bool Determines if this driver can be used based on the environment.
16
+ */
17
+ public static function isSupported (): bool
18
+ {
19
+ return \extension_loaded ('eio ' );
20
+ }
21
+
14
22
public function __construct ()
15
23
{
16
24
$ this ->poll = new Internal \EioPoll ;
Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ class UvDriver implements Driver
20
20
/** @var UvPoll */
21
21
private $ poll ;
22
22
23
+ /**
24
+ * @param \Amp\Loop\Driver The currently active loop driver.
25
+ *
26
+ * @return bool Determines if this driver can be used based on the environment.
27
+ */
28
+ public static function isSupported (Loop \Driver $ driver ): bool
29
+ {
30
+ return $ driver instanceof Loop \UvDriver;
31
+ }
32
+
23
33
/**
24
34
* @param \Amp\Loop\UvDriver $driver
25
35
*/
Original file line number Diff line number Diff line change @@ -41,11 +41,11 @@ function driver(): Driver
41
41
{
42
42
$ driver = Loop::get ();
43
43
44
- if ($ driver instanceof Loop \UvDriver ) {
44
+ if (UvDriver:: isSupported ( $ driver) ) {
45
45
return new UvDriver ($ driver );
46
46
}
47
47
48
- if (\extension_loaded ( " eio " )) {
48
+ if (EioDriver:: isSupported ( )) {
49
49
return new EioDriver ;
50
50
}
51
51
You can’t perform that action at this time.
0 commit comments