コード例 #1
0
ファイル: FormatJob.php プロジェクト: nochso/phormat
 private function showSummary($microseconds)
 {
     $statusFileMap = $this->getFilesGroupedByStatus();
     $changedCount = 0;
     if (isset($statusFileMap[FormatJobFile::STATUS_CHANGED])) {
         $changedCount = count($statusFileMap[FormatJobFile::STATUS_CHANGED]);
     }
     $duration = Duration::create()->format((int) $microseconds) . ' ';
     if ($microseconds < 10) {
         if ($microseconds < 1) {
             $duration = '';
         }
         $duration .= round(($microseconds - (int) $microseconds) * 1000) . 'ms';
     }
     $this->stdio->success(sprintf('Formatted %d file%s in %s.', $changedCount, Quantity::format('(s)', $changedCount), $duration));
 }
コード例 #2
0
ファイル: Application.php プロジェクト: nochso/phormat
 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()));
     }
 }