function test_notify(\cli\Notify $notify, $cycle = 1000000, $sleep = null) { for ($i = 0; $i <= $cycle; $i++) { $notify->tick(); if ($sleep) { usleep($sleep); } } $notify->finish(); }
/** * Instatiates a Notification object. * * @param string $msg The text to display next to the Notifier. * @param int $dots The number of dots to iterate through. * @param int $interval The interval in milliseconds between updates. * @throws \InvalidArgumentException */ public function __construct($msg, $dots = 3, $interval = 100) { parent::__construct($msg, $interval); $this->_dots = (int) $dots; if ($this->_dots <= 0) { throw new \InvalidArgumentException('Dot count out of range, must be positive.'); } }
/** * Forces the current tick count to the total ticks given at instatiation * time before passing on to `cli\Notify::finish()`. */ public function finish() { $this->_current = $this->_total; parent::finish(); }