read(); var_dump($content); $_content = json_decode($content, true); if (is_null($_content)) { $this->jobDelivery($content); } else { $this->otherAction($_content); } } } /** * @param $content */ private function otherAction($content) { call_user_func(match ($content['action']) { 'clear' => function ($content) { if (!isset($this->names[$content['name']])) { return; } $this->names[$content['name']]->clearTimer(); }, 'clearAll' => function () { foreach ($this->names as $name => $crontab) { $crontab->clearTimer(); } }, default => function () { $this->application->error('unknown action'); } }); } /** * @param $content */ private function jobDelivery($content) { $content = unserialize($content); $this->names[$content->getName()] = $content; if (!($content instanceof Crontab)) { return; } $runTicker = [$content, 'execute']; $timer = $content->getTickTime() * 1000; if ($content->isLoop()) { $timerId = Timer::tick($timer, $runTicker); } else { $timerId = Timer::after($timer, $runTicker); } $content->setTimerId($timerId); } }