public function testCollectionClear() { $filter = PHP_Depend_Code_Filter_Collection::getInstance(); $this->assertEquals(0, $filter->getIterator()->count()); $filter->addFilter(new PHP_Depend_Code_Filter_Package(array())); $filter->addFilter(new PHP_Depend_Code_Filter_Package(array())); $this->assertEquals(2, $filter->getIterator()->count()); $filter->clear(); $this->assertEquals(0, $filter->getIterator()->count()); }
/** * testGetParentReturnsNullWhenParentIsFiltered * * @return void * @since 1.0.0 */ public function testGetParentReturnsNullWhenParentIsFiltered() { PHP_Depend_Code_Filter_Collection::getInstance()->setFilter(new PHP_Depend_Code_Filter_Package(array('org.pdepend.filter'))); $class = $this->getFirstClassForTestCase(); $this->assertNull($class->getParentClass()); }
/** * This method performs the analysing process of the parsed source files. It * creates the required analyzers for the registered listeners and then * applies them to the source tree. * * @return void */ private function performAnalyzeProcess() { $analyzerLoader = $this->createAnalyzerLoader($this->options); $collection = PHP_Depend_Code_Filter_Collection::getInstance(); $this->fireStartAnalyzeProcess(); ini_set('xdebug.max_nesting_level', $this->configuration->parser->nesting); foreach ($analyzerLoader as $analyzer) { // Add filters if this analyzer is filter aware if ($analyzer instanceof PHP_Depend_Metrics_FilterAwareI) { $collection->setFilter($this->codeFilter); } $analyzer->analyze($this->builder->getPackages()); // Remove filters if this analyzer is filter aware $collection->setFilter(); foreach ($this->loggers as $logger) { $logger->log($analyzer); } } ini_restore('xdebug.max_nesting_level'); $this->fireEndAnalyzeProcess(); }
/** * Tests that the analyzer calculates the correct average hierarchy height. * * @return void */ public function testAnalyzerCalculatesCorrectAHHValue() { $filter = PHP_Depend_Code_Filter_Collection::getInstance(); $filter->setFilter(new PHP_Depend_Code_Filter_Package(array('library'))); $packages = self::parseTestCaseSource(__METHOD__); $analyzer = new PHP_Depend_Metrics_Inheritance_Analyzer(); $analyzer->analyze($packages); $project = $analyzer->getProjectMetrics(); self::assertEquals(1, $project['ahh']); }
/** * Returns the parent class or <b>null</b> if this class has no parent. * * @return PHP_Depend_Code_Class */ public function getParentClass() { // No parent? Stop here! if ($this->parentClassReference === null) { return null; } $parentClass = $this->parentClassReference->getType(); if ($parentClass === $this) { throw new PHP_Depend_Code_Exceptions_RecursiveInheritanceException($this); } // Check parent against global filter $collection = PHP_Depend_Code_Filter_Collection::getInstance(); if ($collection->accept($parentClass) === false) { return null; } return $parentClass; }
/** * Resets the global iterator filter. * * @return void */ protected function tearDown() { PHP_Depend_Code_Filter_Collection::getInstance()->setFilter(); $this->_clearRunResources(); parent::tearDown(); }
/** * Constructs a new node iterator from the given {@link PHP_Depend_Code_NodeI} * node array. * * @param array(PHP_Depend_Code_NodeI) $nodes List of code nodes. * * @throws RuntimeException If the array contains something different from * a {@link PHP_Depend_Code_NodeI} object. */ public function __construct(array $nodes) { $filter = PHP_Depend_Code_Filter_Collection::getInstance(); $nodeKeys = array(); foreach ($nodes as $node) { $uuid = $node->getUUID(); if (!isset($nodeKeys[$uuid]) && $filter->accept($node)) { $nodeKeys[$uuid] = $uuid; $this->_nodes[] = $node; ++$this->_count; } } }
/** * Returns the parent class or <b>null</b> if this class has no parent. * * @return PHP_Depend_Code_Class */ public function getParentClass() { // No parent? Stop here! if ($this->_parentClassReference === null) { return null; } $parentClass = $this->_parentClassReference->getType(); // Check parent against global filter $collection = PHP_Depend_Code_Filter_Collection::getInstance(); if ($collection->accept($parentClass) === false) { return null; } // Parent is valid, so return return $parentClass; }
/** * Removes the temporary log files. * * @return void */ protected function tearDown() { // Clear filter collection $collection = PHP_Depend_Code_Filter_Collection::getInstance(); $collection->clear(); @unlink($this->resultFile); parent::tearDown(); }
/** * This method performs the analysing process of the parsed source files. It * creates the required analyzers for the registered listeners and then * applies them to the source tree. * * @return void */ private function _performAnalyzeProcess() { $analyzerLoader = $this->_createAnalyzerLoader($this->_options); $collection = PHP_Depend_Code_Filter_Collection::getInstance(); $this->fireStartAnalyzeProcess(); foreach ($analyzerLoader as $analyzer) { // Add filters if this analyzer is filter aware if ($analyzer instanceof PHP_Depend_Metrics_FilterAwareI) { $collection->addFilter($this->_codeFilter); } $analyzer->analyze($this->_builder->getPackages()); // Remove filters if this analyzer is filter aware if ($analyzer instanceof PHP_Depend_Metrics_FilterAwareI) { $collection->removeFilter($this->_codeFilter); } foreach ($this->_loggers as $logger) { $logger->log($analyzer); } } $this->fireEndAnalyzeProcess(); }