Skip to content

Commit

Permalink
Rename property
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jul 24, 2024
1 parent 556bb14 commit e5d135c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
final class Interval
{
private readonly string $watcher;
private readonly string $callbackId;

/**
* @param float $interval Invoke the function every $interval seconds.
Expand All @@ -20,24 +20,24 @@ final class Interval
*/
public function __construct(float $interval, \Closure $closure, bool $reference = true)
{
$this->watcher = EventLoop::repeat($interval, $closure);
$this->callbackId = EventLoop::repeat($interval, $closure);

if (!$reference) {
EventLoop::unreference($this->watcher);
EventLoop::unreference($this->callbackId);
}
}

public function __destruct()
{
EventLoop::cancel($this->watcher);
EventLoop::cancel($this->callbackId);
}

/**
* @return bool True if the internal watcher is referenced.
*/
public function isReferenced(): bool
{
return EventLoop::isReferenced($this->watcher);
return EventLoop::isReferenced($this->callbackId);
}

/**
Expand All @@ -47,7 +47,7 @@ public function isReferenced(): bool
*/
public function reference(): self
{
EventLoop::reference($this->watcher);
EventLoop::reference($this->callbackId);

return $this;
}
Expand All @@ -59,7 +59,7 @@ public function reference(): self
*/
public function unreference(): self
{
EventLoop::unreference($this->watcher);
EventLoop::unreference($this->callbackId);

return $this;
}
Expand All @@ -69,7 +69,7 @@ public function unreference(): self
*/
public function isEnabled(): bool
{
return EventLoop::isEnabled($this->watcher);
return EventLoop::isEnabled($this->callbackId);
}

/**
Expand All @@ -79,7 +79,7 @@ public function isEnabled(): bool
*/
public function enable(): self
{
EventLoop::enable($this->watcher);
EventLoop::enable($this->callbackId);

return $this;
}
Expand All @@ -91,7 +91,7 @@ public function enable(): self
*/
public function disable(): self
{
EventLoop::disable($this->watcher);
EventLoop::disable($this->callbackId);

return $this;
}
Expand Down

0 comments on commit e5d135c

Please sign in to comment.