private function selfUpdate() { $phar = \Phar::running(false); if ($phar === '') { $this->stdio->errln('<<red>>Self-updating only works when running the PHAR version of phormat.<<reset>>'); exit(Status::UNAVAILABLE); } $updater = new Updater($phar, false); $strategy = new GithubStrategy(); $strategy->setPackageName('nochso/phormat'); $strategy->setPharName('phormat.phar'); $strategy->setCurrentLocalVersion($this->version->getVersion()); $updater->setStrategyObject($strategy); try { if ($updater->update()) { $this->stdio->success(sprintf('Successfully updated phormat from <<yellow>>%s<<reset>> to <<yellow>>%s<<reset>>.', $updater->getOldVersion(), $updater->getNewVersion())); exit(Status::SUCCESS); } $this->stdio->neutral('There is no update available.'); exit(Status::SUCCESS); } catch (\Exception $e) { $this->stdio->error(sprintf("Self-update failed:\n%s<<reset>>", $e->getMessage())); } }
/** * @return string */ public function getVersion() { return $this->version->getVersion(); }