/** * Find latest release in github API and get required info */ private function findLatestVersion() { // get remote api with json response $gitJson = File::getFromUrl(static::API_LATEST_RELEASE); if ($gitJson === null || $gitJson === false) { return; } // parse api response to model attributes $git = json_decode($gitJson, true); $this->lastVersion = $git['tag_name']; // get download url to full compiled distributive (uploaded to each release as .zip archive, placed in release.assets) $download = null; if (Obj::isArray($git['assets'])) { foreach ($git['assets'] as $asset) { if ($asset['content_type'] === 'application/zip' && $asset['state'] === 'uploaded') { $download = $asset['browser_download_url']; } } } $this->lastInfo = ['name' => $git['name'], 'created_at' => Date::convertToDatetime($git['published_at'], Date::FORMAT_TO_HOUR), 'download_url' => $download]; }
/** * Download remote content in binary string * @param string $url * @return null|string * @deprecated */ public static function download($url) { return File::getFromUrl($url); }