Example #1
0
 /**
  * Run PHPCA. Parses the command line and executes the selected command.
  *
  * @param array $arguments $argv
  */
 public function run($arguments)
 {
     print 'PHP Code Analyzer ' . Application::$version . ' by Stefan Priebsch.' . PHP_EOL . PHP_EOL;
     try {
         $this->startTimer();
         $method = $this->parseCommandLine($arguments);
         print 'Coding standard: ' . $this->codingStandard . PHP_EOL;
         if (!is_null($this->configurationFile)) {
             print 'Configuration: ' . $this->configurationFile . PHP_EOL;
         }
         $rules = $this->configuration->getRules();
         if (sizeof($rules) != 0) {
             print PHP_EOL . 'Rules: ' . implode(', ', $rules) . PHP_EOL;
         }
         print PHP_EOL;
         $this->result = $this->{$method}();
         $this->endTimer();
         // Only print the summary when we actually analyzed files
         if ($method == 'analyzeFilesCommand') {
             $this->printSummary();
             if ($this->printStatistics) {
                 $this->printStatistics();
             }
         }
         if ($this->result->hasErrors()) {
             $this->doExit(-1);
         }
     } catch (Exception $e) {
         print 'Error: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
         $this->printUsageMessage();
         $this->doExit(-1);
     }
 }