storeLocal(self::TLS_KEY_UPDATER, $updater); $this->endpoint = $endpoint; $this->channel = $channel; } public function onRun() : void{ $error = ""; $response = Internet::getURL($this->endpoint . "?channel=" . $this->channel, 4, [], $error); $this->error = $error; if($response !== false){ $response = json_decode($response, true); if(is_array($response)){ if( isset($response["base_version"]) and isset($response["is_dev"]) and isset($response["build"]) and isset($response["date"]) and isset($response["download_url"]) ){ $response["details_url"] = $response["details_url"] ?? null; $this->setResult($response); }elseif(isset($response["error"])){ $this->error = $response["error"]; }else{ $this->error = "Invalid response data"; } }else{ $this->error = "Invalid response data"; } } } public function onCompletion() : void{ /** @var AutoUpdater $updater */ $updater = $this->fetchLocal(self::TLS_KEY_UPDATER); if($this->hasResult()){ $updater->checkUpdateCallback($this->getResult()); }else{ $updater->checkUpdateError($this->error); } } }