Exemple #1
0
 /**
  * Starts the main PDepend process and returns <b>true</b> after a successful
  * execution.
  *
  * @return boolean
  * @throws RuntimeException An exception with a readable error message and
  * an exit code.
  */
 public function run()
 {
     $pdepend = new PHP_Depend();
     $pdepend->setOptions($this->_options);
     foreach ($this->_optimizations[$this->_optimization] as $type => $class) {
         // Import storage engine class definition
         if (class_exists($class) === false) {
             include_once strtr($class, '_', '/') . '.php';
         }
         $pdepend->setStorage($type, new $class());
     }
     if (count($this->_extensions) > 0) {
         $filter = new PHP_Depend_Input_ExtensionFilter($this->_extensions);
         $pdepend->addFileFilter($filter);
     }
     if (count($this->_excludeDirectories) > 0) {
         $exclude = $this->_excludeDirectories;
         $filter = new PHP_Depend_Input_ExcludePathFilter($exclude);
         $pdepend->addFileFilter($filter);
     }
     if (count($this->_excludePackages) > 0) {
         $exclude = $this->_excludePackages;
         $filter = new PHP_Depend_Code_Filter_Package($exclude);
         $pdepend->setCodeFilter($filter);
     }
     if ($this->_withoutAnnotations === true) {
         $pdepend->setWithoutAnnotations();
     }
     // Try to set all source directories.
     try {
         foreach ($this->_sourceArguments as $sourceArgument) {
             if (is_file($sourceArgument)) {
                 $pdepend->addFile($sourceArgument);
             } else {
                 $pdepend->addDirectory($sourceArgument);
             }
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), self::EXCEPTION_EXIT);
     }
     if (count($this->_loggerMap) === 0) {
         throw new RuntimeException('No output specified.', self::EXCEPTION_EXIT);
     }
     $loggerFactory = new PHP_Depend_Log_LoggerFactory();
     // To append all registered loggers.
     try {
         foreach ($this->_loggerMap as $loggerID => $logFileName) {
             // Create a new logger
             $logger = $loggerFactory->createLogger($loggerID, $logFileName);
             $pdepend->addLogger($logger);
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), self::EXCEPTION_EXIT);
     }
     foreach ($this->_processListeners as $processListener) {
         $pdepend->addProcessListener($processListener);
     }
     try {
         $pdepend->analyze();
         foreach ($pdepend->getExceptions() as $exception) {
             $this->_parseErrors[] = $exception->getMessage();
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), self::EXCEPTION_EXIT);
     }
     return self::SUCCESS_EXIT;
 }
Exemple #2
0
 /**
  * Tests that {@link PHP_Depend_Log_LoggerFactory::createLogger()} fails with
  * an exception for an invalid logger identifier.
  *
  * @return void
  */
 public function testCreateLoggerWithInvalidIdentifierFail()
 {
     $this->setExpectedException('RuntimeException', "Unknown logger class 'PHP_Depend_Log_FooBar_Xml'.");
     $factory = new PHP_Depend_Log_LoggerFactory();
     $factory->createLogger('foo-bar-xml', 'pdepend.xml');
 }
Exemple #3
0
 /**
  * Starts the main PDepend process and returns <b>true</b> after a successful
  * execution.
  *
  * @return boolean
  * @throws RuntimeException An exception with a readable error message and
  * an exit code.
  */
 public function run()
 {
     $pdepend = new PHP_Depend($this->configuration);
     $pdepend->setOptions($this->options);
     if (count($this->extensions) > 0) {
         $filter = new PHP_Depend_Input_ExtensionFilter($this->extensions);
         $pdepend->addFileFilter($filter);
     }
     if (count($this->excludeDirectories) > 0) {
         $exclude = $this->excludeDirectories;
         $filter = new PHP_Depend_Input_ExcludePathFilter($exclude);
         $pdepend->addFileFilter($filter);
     }
     if (count($this->excludePackages) > 0) {
         $exclude = $this->excludePackages;
         $filter = new PHP_Depend_Code_Filter_Package($exclude);
         $pdepend->setCodeFilter($filter);
     }
     if ($this->withoutAnnotations === true) {
         $pdepend->setWithoutAnnotations();
     }
     // Try to set all source directories.
     try {
         foreach ($this->sourceArguments as $sourceArgument) {
             if (is_file($sourceArgument)) {
                 $pdepend->addFile($sourceArgument);
             } else {
                 $pdepend->addDirectory($sourceArgument);
             }
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), self::EXCEPTION_EXIT);
     }
     if (count($this->loggerMap) === 0) {
         throw new RuntimeException('No output specified.', self::EXCEPTION_EXIT);
     }
     $loggerFactory = new PHP_Depend_Log_LoggerFactory();
     // To append all registered loggers.
     try {
         foreach ($this->loggerMap as $loggerID => $logFileName) {
             // Create a new logger
             $logger = $loggerFactory->createLogger($loggerID, $logFileName);
             $pdepend->addLogger($logger);
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), self::EXCEPTION_EXIT);
     }
     foreach ($this->processListeners as $processListener) {
         $pdepend->addProcessListener($processListener);
     }
     try {
         $pdepend->analyze();
         foreach ($pdepend->getExceptions() as $exception) {
             $this->parseErrors[] = $exception->getMessage();
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), self::EXCEPTION_EXIT);
     }
     return self::SUCCESS_EXIT;
 }