Returns an array of all afferent nodes.
public getAfferents ( PDepend\Source\AST\AbstractASTArtifact $node ) : PDepend\Source\AST\AbstractASTArtifact[] | ||
$node | PDepend\Source\AST\AbstractASTArtifact | |
리턴 | PDepend\Source\AST\AbstractASTArtifact[] |
/** * Visits a package node. * * @param \PDepend\Source\AST\ASTNamespace $namespace * @return void */ public function visitNamespace(ASTNamespace $namespace) { if (!$namespace->isUserDefined()) { return; } $stats = $this->analyzer->getStats($namespace); if (count($stats) === 0) { return; } $doc = $this->packages->ownerDocument; $this->concreteClasses = $doc->createElement('ConcreteClasses'); $this->abstractClasses = $doc->createElement('AbstractClasses'); $packageXml = $doc->createElement('Package'); $packageXml->setAttribute('name', $namespace->getName()); $statsXml = $doc->createElement('Stats'); $statsXml->appendChild($doc->createElement('TotalClasses'))->appendChild($doc->createTextNode($stats['tc'])); $statsXml->appendChild($doc->createElement('ConcreteClasses'))->appendChild($doc->createTextNode($stats['cc'])); $statsXml->appendChild($doc->createElement('AbstractClasses'))->appendChild($doc->createTextNode($stats['ac'])); $statsXml->appendChild($doc->createElement('Ca'))->appendChild($doc->createTextNode($stats['ca'])); $statsXml->appendChild($doc->createElement('Ce'))->appendChild($doc->createTextNode($stats['ce'])); $statsXml->appendChild($doc->createElement('A'))->appendChild($doc->createTextNode($stats['a'])); $statsXml->appendChild($doc->createElement('I'))->appendChild($doc->createTextNode($stats['i'])); $statsXml->appendChild($doc->createElement('D'))->appendChild($doc->createTextNode($stats['d'])); $dependsUpon = $doc->createElement('DependsUpon'); foreach ($this->analyzer->getEfferents($namespace) as $efferent) { $efferentXml = $doc->createElement('Package'); $efferentXml->appendChild($doc->createTextNode($efferent->getName())); $dependsUpon->appendChild($efferentXml); } $usedBy = $doc->createElement('UsedBy'); foreach ($this->analyzer->getAfferents($namespace) as $afferent) { $afferentXml = $doc->createElement('Package'); $afferentXml->appendChild($doc->createTextNode($afferent->getName())); $usedBy->appendChild($afferentXml); } $packageXml->appendChild($statsXml); $packageXml->appendChild($this->concreteClasses); $packageXml->appendChild($this->abstractClasses); $packageXml->appendChild($dependsUpon); $packageXml->appendChild($usedBy); if (($cycles = $this->analyzer->getCycle($namespace)) !== null) { $cycleXml = $doc->createElement('Package'); $cycleXml->setAttribute('Name', $namespace->getName()); foreach ($cycles as $cycle) { $cycleXml->appendChild($doc->createElement('Package'))->appendChild($doc->createTextNode($cycle->getName())); } $this->cycles->appendChild($cycleXml); } foreach ($namespace->getTypes() as $type) { $type->accept($this); } if ($this->concreteClasses->firstChild === null && $this->abstractClasses->firstChild === null) { return; } $this->packages->appendChild($packageXml); }
/** * Aggregates all dependencies for the given <b>$node</b> instance and adds them * to the <b>\DOMElement</b> * * @param \DOMElement $xml * @param \PDepend\Source\AST\AbstractASTArtifact $node * @return void */ protected function writeNodeDependencies(\DOMElement $xml, AbstractASTArtifact $node) { if (!$this->dependencyAnalyzer) { return; } $xml = end($this->xmlStack); $doc = $xml->ownerDocument; $efferentXml = $doc->createElement('efferent'); $xml->appendChild($efferentXml); foreach ($this->dependencyAnalyzer->getEfferents($node) as $type) { $typeXml = $doc->createElement('type'); $typeXml->setAttribute('namespace', Utf8Util::ensureEncoding($type->getNamespaceName())); $typeXml->setAttribute('name', Utf8Util::ensureEncoding($type->getName())); $efferentXml->appendChild($typeXml); } $afferentXml = $doc->createElement('afferent'); $xml->appendChild($afferentXml); foreach ($this->dependencyAnalyzer->getAfferents($node) as $type) { $typeXml = $doc->createElement('type'); $typeXml->setAttribute('namespace', Utf8Util::ensureEncoding($type->getNamespaceName())); $typeXml->setAttribute('name', Utf8Util::ensureEncoding($type->getName())); $afferentXml->appendChild($typeXml); } }