/** * Load all reporters from the XML and register them in the configuration. * * @param Configuration $config * @param DOMXPath $xpath */ public function loadReporters(Configuration $config, DOMXPath $xpath) { $reporters = $xpath->query('reporters/reporter'); foreach ($reporters as $reporter) { // Get the type of reporter from the attribute and check it. $type = $reporter->getAttribute('type'); if ($type === '') { throw new RuntimeException('The <reporter> element is missing the type attribute.'); } $config->addReporter($this->createReporter($type, $reporter->nodeValue)); } }
/** * Resolve the target argument to a list of files to process. * * @param InputInterface $input * @return array<SplFileInfo> */ public function resolveTargets(Configuration $config) { $targets = array(); $fs = $this->getFilesystem(); // Add all files from the configuration file. foreach ($config->getFiles() as $file) { // Check if the file exists. if ($fs->isFile($file) === false) { throw new RuntimeException('The target file ' . $file . ' does not exist.'); } $targets[] = new SplFileInfo($file); } // Add all directories from the configuration file. foreach ($config->getDirectories() as $directory) { list($path, $suffix) = $directory; // Check if the path exists. if ($fs->isDirectory($path) === false) { throw new RuntimeException('The target directory ' . $path . ' does not exist.'); } // Otherwise, recursively find files. $files = iterator_to_array($this->getFinder()->files()->name('*' . $suffix)->in($path)); $targets = array_merge($targets, $files); } return $targets; }