/** * Assign CLI arguments to current runner instance * * @return bool */ protected function assignArguments() { if ($this->source) { $this->runner->setSourceArguments($this->source); } // Check for suffix option if (isset($this->options['--suffix'])) { // Get file extensions $extensions = explode(',', $this->options['--suffix']); // Set allowed file extensions $this->runner->setFileExtensions($extensions); unset($this->options['--suffix']); } // Check for ignore option if (isset($this->options['--ignore'])) { // Get exclude directories $directories = explode(',', $this->options['--ignore']); // Set exclude directories $this->runner->setExcludeDirectories($directories); unset($this->options['--ignore']); } // Check for exclude namespace option if (isset($this->options['--exclude'])) { // Get exclude directories $namespaces = explode(',', $this->options['--exclude']); // Set exclude namespace $this->runner->setExcludeNamespaces($namespaces); unset($this->options['--exclude']); } // Check for the bad documentation option if (isset($this->options['--bad-documentation'])) { echo "Option --bad-documentation is ambiguous.", PHP_EOL; unset($this->options['--bad-documentation']); } $configuration = $this->application->getConfiguration(); // Store in config registry ConfigurationInstance::set($configuration); if (isset($this->options['--debug'])) { unset($this->options['--debug']); Log::setSeverity(Log::DEBUG); } }
/** * Executes the runner class and returns an array with namespace statistics. * * @param \PDepend\TextUI\Runner $runner The runner instance. * @param $pathName The source path. * @return array */ private function _runRunnerAndReturnStatistics(Runner $runner, $pathName) { $logFile = self::createRunResourceURI(); $runner->setSourceArguments(array($pathName)); $runner->addReportGenerator('dummy-logger', $logFile); $this->silentRun($runner); $data = unserialize(file_get_contents($logFile)); $code = $data['code']; $actual = array(); foreach ($code as $namespace) { $statistics = array('functions' => array(), 'classes' => array(), 'interfaces' => array(), 'exceptions' => array()); foreach ($namespace->getFunctions() as $function) { $statistics['functions'][] = $function->getName(); foreach ($function->getExceptionClasses() as $exception) { $statistics['exceptions'][] = $exception->getName(); } } foreach ($namespace->getClasses() as $class) { $statistics['classes'][] = $class->getName(); } foreach ($namespace->getInterfaces() as $interface) { $statistics['interfaces'][] = $interface->getName(); } sort($statistics['functions']); sort($statistics['classes']); sort($statistics['interfaces']); sort($statistics['exceptions']); $actual[$namespace->getName()] = $statistics; } ksort($actual); return $actual; }