PDepend\Engine::addFile PHP Method

addFile() public method

Adds a single source code file to the list of files to be analysed.
public addFile ( string $file ) : void
$file string The source file name.
return void
    public function addFile($file)
    {
        if ($file === '-' || $file === 'php://stdin') {
            $fileName = 'php://stdin';
        } else {
            $fileName = realpath($file);
            if (!is_file($fileName)) {
                throw new \InvalidArgumentException(sprintf('The given file "%s" does not exist.', $file));
            }
        }
        $this->files[] = $fileName;
    }

Usage Example

Beispiel #1
0
 /**
  * Configures the input source.
  *
  * @param PDepend\Engine $pdepend The context php depend instance.
  * @param PHP_PMD    $phpmd   The calling/parent php mess detector.
  *
  * @return void
  */
 private function initInput(PDepend\Engine $pdepend, PHP_PMD $phpmd)
 {
     foreach (explode(',', $phpmd->getInput()) as $path) {
         if (is_dir(trim($path))) {
             $pdepend->addDirectory(trim($path));
         } else {
             $pdepend->addFile(trim($path));
         }
     }
 }