Skip to content

Update Timer.php #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Timer/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace React\EventLoop\Timer;


use React\EventLoop\TimerInterface;

/**
Expand All @@ -12,13 +13,14 @@
* @see TimerInterface
* @internal
*/
final class Timer implements TimerInterface
final class CustomTimer implements TimerInterface
{
const MIN_INTERVAL = 0.000001;

private $interval;
private $callback;
private $periodic;
private $userdata;

/**
* Constructor initializes the fields of the Timer
Expand All @@ -27,7 +29,7 @@ final class Timer implements TimerInterface
* @param callable $callback The callback that will be executed when this timer elapses
* @param bool $periodic Whether the time is periodic
*/
public function __construct($interval, $callback, $periodic = false)
public function __construct($interval, $callback, $periodic = false, $userdata = null)
{
if ($interval < self::MIN_INTERVAL) {
$interval = self::MIN_INTERVAL;
Expand All @@ -36,6 +38,7 @@ public function __construct($interval, $callback, $periodic = false)
$this->interval = (float) $interval;
$this->callback = $callback;
$this->periodic = (bool) $periodic;
$this->userdata = $userdata;
}

public function getInterval()
Expand All @@ -52,4 +55,11 @@ public function isPeriodic()
{
return $this->periodic;
}

public function getUserdata()
{
return $this->userdata;
}
}