8000 Documentation for timer API and clean up unneeded timer API by clue · Pull Request #102 · reactphp/event-loop · GitHub
[go: up one dir, main page]

Skip to content

Documentation for timer API and clean up unneeded timer API #102

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

Merged
merged 5 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove unneeded and undocumented timer data, use closure binding instead
The mixed "data" attribute is mostly unused and can easily be replaced
by closure binding instead.

This also prepares the timer instance to become an immutable
data structure.
  • Loading branch information
clue committed Apr 26, 2017
commit 7eb31c1fa9d801b18b9c56e8fc4d0a47bf109ba9
21 changes: 1 addition & 20 deletions src/Timer/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Timer implements TimerInterface
protected $interval;
protected $callback;
protected $periodic;
protected $data;

/**
* Constructor initializes the fields of the Timer
Expand All @@ -21,9 +20,8 @@ class Timer implements TimerInterface
* @param float $interval The interval after which this timer will execute, in seconds
* @param callable $callback The callback that will be executed when this timer elapses
* @param bool $periodic Whether the time is periodic
* @param mixed $data Arbitrary data associated with timer
*/
public function __construct(LoopInterface $loop, $interval, callable $callback, $periodic = false, $data = null)
public function __construct(LoopInterface $loop, $interval, callable $callback, $periodic = false)
{
if ($interval < self::MIN_INTERVAL) {
$interval = self::MIN_INTERVAL;
Expand All @@ -33,7 +31,6 @@ public function __construct(LoopInterface $loop, $interval, callable $callback,
$this->interval = (float) $interval;
$this->callback = $callback;
$this->periodic = (bool) $periodic;
$this->data = null;
}

/**
Expand All @@ -60,22 +57,6 @@ public function getCallback()
return $this->callback;
}

/**
* {@inheritdoc}
*/
public function setData($data)
{
$this->data = $data;
}

/**
* {@inheritdoc}
*/
public function getData()
{
return $this->data;
}

/**
* {@inheritdoc}
*/
Expand Down
14 changes: 0 additions & 14 deletions src/Timer/TimerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ public function getInterval();
*/
public function getCallback();

/**
* Set arbitrary data associated with timer
*
* @param mixed $data
*/
public function setData($data);

/**
* Get arbitrary data associated with timer
*
* @return mixed
*/
public function getData();

/**
* Determine whether the time is periodic
*
Expand Down
0