Skip to content

Commit

Permalink
Fix timeLimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasil coylOne Kulakov committed Aug 28, 2017
1 parent b94fefb commit 297dfdf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/EventBand/Processor/Control/TimeLimiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct($limit)
}
$this->limit = $limit;

$this->startTime = 0;
$this->initTimer();
}

public function initTimer()
Expand All @@ -32,11 +32,11 @@ public function initTimer()

public function checkLimit(StoppableDispatchEvent $event)
{
$now = time();
if ($this->startTime + $this->limit >= $now) {
$timeLeft = $this->startTime + $this->limit - time();
if ($timeLeft <= 0) {
$event->stopDispatching();
return 0;
}
return (int) ($this->startTime + $this->limit - $now);
return $timeLeft;
}
}

0 comments on commit 297dfdf

Please sign in to comment.