/** * Gestion du temps de temporisation */ public function testSleep() { $this->given($command = new TestClass('toto'))->boolean($command->getSleep())->isFalse()->object($command->setSleep(5))->isIdenticalTo($command)->integer($command->getSleep())->isEqualTo(5); }
/** * Temporisation * * @param Command $command Command courante */ private function sleep(Command $command) { if ($command->getSleep() === false) { return; } $progress = null; foreach ($this->plugins as $plugin) { if (method_exists($plugin, 'getTickSleep')) { $progress = $plugin->getTickSleep(); break; } } for ($i = $command->getSleep(); $i > 0; $i--) { if (is_callable($progress)) { $progress($i); } sleep(1); } }