read(); $_content = json_decode($content, true); if (is_null($_content)) { $this->jobDelivery($content); } else { $this->otherAction($_content); } } catch (\Throwable $exception) { $this->application->error($exception->getMessage()); } } } /** * @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'); } }, $content); } /** * @param $content */ private function jobDelivery($content) { /** @var Crontab $content */ $content = unserialize($content); $runTicker = function (Crontab $crontab) { var_dump(get_called_class()); $crontab->execute(); }; $timer = $content->getTickTime() * 1000; var_dump($timer); if ($content->isLoop()) { $content->setTimerId(Timer::tick($timer, $runTicker, $content)); } else { $content->setTimerId(Timer::after($timer, $runTicker, $content)); } $this->names[$content->getName()] = $content; } }