/**
  * This method will return an <b>array</b> with all generated metric values
  * for the node with the given <b>$id</b> identifier. If there are no
  * metrics for the requested node, this method will return an empty <b>array</b>.
  *
  * <code>
  * array(
  *     'loc'    =>  42,
  *     'ncloc'  =>  17,
  *     'cc'     =>  12
  * )
  * </code>
  *
  * @param \PDepend\Source\AST\ASTArtifact $artifact
  * @return array(string=>mixed)
  */
 public function getNodeMetrics(ASTArtifact $artifact)
 {
     if (isset($this->nodeMetrics[$artifact->getId()])) {
         return $this->nodeMetrics[$artifact->getId()];
     }
     return array();
 }
 /**
  * Returns <b>true</b> if the given node should be part of the node iterator,
  * otherwise this method will return <b>false</b>.
  *
  * @param \PDepend\Source\AST\ASTArtifact $node
  * @return boolean
  */
 public function accept(ASTArtifact $node)
 {
     $namespace = null;
     // NOTE: This looks a little bit ugly and it seems better to exclude
     //       \PDepend\Source\AST\ASTMethod and \PDepend\Source\AST\ASTProperty,
     //       but when PDepend supports more node types, this could produce errors.
     if ($node instanceof AbstractASTClassOrInterface) {
         $namespace = $node->getNamespace()->getName();
     } elseif ($node instanceof ASTFunction) {
         $namespace = $node->getNamespace()->getName();
     } elseif ($node instanceof ASTNamespace) {
         $namespace = $node->getName();
     }
     return preg_match($this->pattern, $namespace) === 0;
 }
Example #3
0
 /**
  * This method will return an <b>array</b> with all generated metric values
  * for the given <b>$node</b> instance. If there are no metrics for the
  * requested node, this method will return an empty <b>array</b>.
  *
  * <code>
  * array(
  *     'loc'    =>  23,
  *     'cloc'   =>  17,
  *     'eloc'   =>  17,
  *     'ncloc'  =>  42
  * )
  * </code>
  *
  * @param  \PDepend\Source\AST\ASTArtifact $artifact
  * @return array
  */
 public function getNodeMetrics(ASTArtifact $artifact)
 {
     $metrics = array();
     if (isset($this->metrics[$artifact->getId()])) {
         $metrics = $this->metrics[$artifact->getId()];
     }
     return $metrics;
 }
Example #4
0
 /**
  * Returns the name of the declaring source file.
  *
  * @return string
  */
 public function getFileName()
 {
     return (string) $this->node->getCompilationUnit()->getFileName();
 }
 /**
  * This method will return an <b>array</b> with all generated metric values
  * for the node with the given <b>$id</b> identifier. If there are no
  * metrics for the requested node, this method will return an empty <b>array</b>.
  *
  * <code>
  * array(
  *     'npath'  =>  '17'
  * )
  * </code>
  *
  * @param  \PDepend\Source\AST\ASTArtifact $artifact
  * @return array
  */
 public function getNodeMetrics(ASTArtifact $artifact)
 {
     $metric = array();
     if (isset($this->metrics[$artifact->getId()])) {
         $metric = array(self::M_NPATH_COMPLEXITY => $this->metrics[$artifact->getId()]);
     }
     return $metric;
 }