/** * Returns true do indicate it should be run again or false to indicate * it should not be run again. * * @param Queue $queue * @param array $options * * @return bool */ public function tick(Queue $queue, array $options = []) { $this->configure($options); if ($this->shutdown) { return false; } if (microtime(true) > $this->options['max-runtime']) { return false; } if ($this->pause) { return true; } $this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue)); if (!($envelope = $queue->dequeue())) { return !$this->options['stop-when-empty']; } $this->invoke($envelope, $queue); if (null === $this->options['max-messages']) { return true; } return (bool) --$this->options['max-messages']; }