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())); } }
public function testGetInfoLong() { $version = new VersionInfo('Name', '0.1.0', VersionInfo::INFO_FORMAT_LONG); $this->assertSame('Name (Version 0.1.0)', $version->getInfo()); }
/** * @return string */ public function getName() { return $this->version->getName(); }