/** * Dispatches the request to a task handler. * * @throws \WordPress\Cli\Task\NotHandledException * @throws \WordPress\Cli\Exception * * @return mixed */ public function handle() { $task = $this->request->getTask(); $handler = $this->resolveHandler($task); $action = $this->request->getAction(); $method = empty($action) ? $this->defaultActionMethod : $action . $this->actionMethodSuffix; if (!method_exists($handler, $method)) { throw new Task\NotHandledException("'{$method}' method not found on handler."); } $handler->setRequest($this->request); $handler->setIo($this->io); return $this->invokeHandler($handler, $method); }