/**
  * This method will create a single rule instance and add it to the given
  * {@link PHP_PMD_RuleSet} object.
  *
  * @param PHP_PMD_RuleSet  $ruleSet  The parent rule-set instance.
  * @param SimpleXMLElement $ruleNode The context rule-set xml node.
  *
  * @return void
  * @throws PHP_PMD_RuleClassFileNotFoundException When a class file does not
  *                                                exist.
  * @throws PHP_PMD_RuleClassNotFoundException When a configured rule class
  *                                            does not exist.
  */
 private function parseSingleRuleNode(PHP_PMD_RuleSet $ruleSet, SimpleXMLElement $ruleNode)
 {
     $className = (string) $ruleNode['class'];
     $fileName = strtr($className, '_', '/') . '.php';
     if (class_exists($className) === false) {
         $handle = @fopen($fileName, 'r', true);
         if ($handle === false) {
             throw new PHP_PMD_RuleClassFileNotFoundException($className);
         }
         fclose($handle);
         include_once $fileName;
         if (class_exists($className) === false) {
             throw new PHP_PMD_RuleClassNotFoundException($className);
         }
     }
     /* @var $rule PHP_PMD_Rule */
     $rule = new $className();
     $rule->setName((string) $ruleNode['name']);
     $rule->setMessage((string) $ruleNode['message']);
     $rule->setExternalInfoUrl((string) $ruleNode['externalInfoUrl']);
     $rule->setRuleSetName($ruleSet->getName());
     if (trim($ruleNode['since']) !== '') {
         $rule->setSince((string) $ruleNode['since']);
     }
     foreach ($ruleNode->children() as $node) {
         if ($node->getName() === 'description') {
             $rule->setDescription((string) $node);
         } else {
             if ($node->getName() === 'example') {
                 $rule->addExample((string) $node);
             } else {
                 if ($node->getName() === 'priority') {
                     $rule->setPriority((int) $node);
                 } else {
                     if ($node->getName() === 'properties') {
                         $this->parsePropertiesNode($rule, $node);
                     }
                 }
             }
         }
     }
     if ($rule->getPriority() <= $this->minimumPriority) {
         $ruleSet->addRule($rule);
     }
 }