mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
Remove superfluous Reactor::at() method
This commit is contained in:
parent
af2335cf50
commit
cd84401b6f
@ -129,27 +129,6 @@ class LibeventReactor implements SignalReactor {
|
||||
$this->isRunning = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws \InvalidArgumentException On invalid future time
|
||||
*/
|
||||
public function at(callable $callback, $unixTimeOrStr): string {
|
||||
$now = time();
|
||||
if (is_int($unixTimeOrStr) && $unixTimeOrStr > $now) {
|
||||
$secondsUntil = ($unixTimeOrStr - $now);
|
||||
} elseif (($executeAt = @strtotime($unixTimeOrStr)) && $executeAt > $now) {
|
||||
$secondsUntil = ($executeAt - $now);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
"Unix timestamp or future time string (parsable by strtotime()) required"
|
||||
);
|
||||
}
|
||||
|
||||
$msDelay = $secondsUntil * $this->resolution;
|
||||
|
||||
return $this->once($callback, $msDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -213,26 +213,6 @@ class NativeReactor implements Reactor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function at(callable $callback, $unixTimeOrStr): string {
|
||||
$now = time();
|
||||
if (is_int($unixTimeOrStr) && $unixTimeOrStr > $now) {
|
||||
$secondsUntil = ($unixTimeOrStr - $now);
|
||||
} elseif (($executeAt = @strtotime($unixTimeOrStr)) && $executeAt > $now) {
|
||||
$secondsUntil = ($executeAt - $now);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
'Unix timestamp or future time string (parsable by strtotime()) required'
|
||||
);
|
||||
}
|
||||
|
||||
$msDelay = $secondsUntil * $this->resolution;
|
||||
|
||||
return $this->once($callback, $msDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -52,15 +52,6 @@ interface Reactor {
|
||||
*/
|
||||
public function repeat(callable $func, int $millisecondDelay): string;
|
||||
|
||||
/**
|
||||
* Schedule an event to trigger once at the specified time
|
||||
*
|
||||
* @param callable $func A callback to invoke at the specified future time
|
||||
* @param int|string $unixTimeOrStr
|
||||
* @return string Returns unique (to the process) string watcher ID
|
||||
*/
|
||||
public function at(callable $func, $unixTimeOrStr): string;
|
||||
|
||||
/**
|
||||
* Watch a stream resource for readable data and trigger the callback when actionable
|
||||
*
|
||||
|
@ -228,26 +228,6 @@ class UvReactor implements SignalReactor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function at(callable $callback, $unixTimeOrStr): string {
|
||||
$now = time();
|
||||
if (is_int($unixTimeOrStr) && $unixTimeOrStr > $now) {
|
||||
$secondsUntil = ($unixTimeOrStr - $now);
|
||||
} elseif (($executeAt = @strtotime($unixTimeOrStr)) && $executeAt > $now) {
|
||||
$secondsUntil = ($executeAt - $now);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
'Unix timestamp or future time string (parsable by strtotime()) required'
|
||||
);
|
||||
}
|
||||
|
||||
$msDelay = $secondsUntil * $this->resolution;
|
||||
|
||||
return $this->once($callback, $msDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user