/** * Returns an iterator with all generated {@link PHP_Depend_Code_Package} * objects. * * @return PHP_Depend_Code_NodeIterator */ public function getPackages() { // Create a package array copy $packages = $this->_packages; // Remove default package if empty if ($this->defaultPackage->getTypes()->count() === 0 && $this->defaultPackage->getFunctions()->count() === 0) { unset($packages[self::DEFAULT_PACKAGE]); } return new PHP_Depend_Code_NodeIterator($packages); }
/** * Tests that the {@link PHP_Depend_Code_Package::removeFunction()} method * unsets the actual package as {@link PHP_Depend_Code_Function} owner. * * @return void * @covers PHP_Depend_Code_Package * @group pdepend * @group pdepend::code * @group unittest */ public function testRemoveFunction() { $package = new PHP_Depend_Code_Package('package1'); $function1 = new PHP_Depend_Code_Function('func1', 0); $function2 = new PHP_Depend_Code_Function('func2', 0); $package->addFunction($function1); $package->addFunction($function2); $package->removeFunction($function2); $this->assertEquals(1, $package->getFunctions()->count()); }
/** * Returns an iterator with all generated {@link PHP_Depend_Code_Package} * objects. * * @return PHP_Depend_Code_NodeIterator * @since 0.9.12 */ private function _getPreparedPackages() { // Create a package array copy $packages = $this->_packages; // Remove default package if empty if ($this->defaultPackage->getTypes()->count() === 0 && $this->defaultPackage->getFunctions()->count() === 0) { unset($packages[self::DEFAULT_PACKAGE]); } return $packages; }