Inheritance: extends AbstractUnitObject
Beispiel #1
0
 public function getUnitByName($name)
 {
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->queryOne(sprintf('//phpdox:namespace[@name="%s"]/*[@name="%s"]', $namespace, $local));
     if (!$indexNode) {
         return;
     }
     $dom = new fDOMDocument();
     $dom->load($this->baseDir . '/' . $indexNode->getAttribute('xml'));
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             $unit->import($dom);
             $this->project->addInterface($unit);
             break;
         case 'trait':
             $unit = new TraitObject();
             $unit->import($dom);
             $this->project->addTrait($unit);
             break;
         case 'class':
             $unit = new ClassObject();
             $unit->import($dom);
             $this->project->addClass($unit);
             break;
     }
     return $unit;
 }
Beispiel #2
0
 public function getUnitByName($name)
 {
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->queryOne(sprintf('//phpdox:namespace[@name="%s"]/*[@name="%s"]', $namespace, $local));
     if (!$indexNode) {
         throw new DependencyException(sprintf("Unit '%s' not found", $name), DependencyException::UnitNotFound);
     }
     $dom = new fDOMDocument();
     $dom->load($this->baseDir . '/' . $indexNode->getAttribute('xml'));
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             $unit->import($dom);
             $this->project->addInterface($unit);
             break;
         case 'trait':
             $unit = new TraitObject();
             $unit->import($dom);
             $this->project->addTrait($unit);
             break;
         case 'class':
             $unit = new ClassObject();
             $unit->import($dom);
             $this->project->addClass($unit);
             break;
         default:
             throw new DependencyException(sprintf("Invalid unit type '%s'", $indexNode->localName), DependencyException::InvalidUnitType);
     }
     return $unit;
 }
Beispiel #3
0
 /**
  * @param $namespace
  * @param $name
  * @return fDOMElement
  */
 public function getUnitByName($name)
 {
     if (isset($this->loadedUnits[$name])) {
         return $this->loadedUnits[$name];
     }
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->findUnitNodeByName($namespace, $local);
     if (!$indexNode) {
         throw new ProjectException("No unit with name '{$name}' found");
     }
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             break;
         case 'trait':
             $unit = new TraitObject();
             break;
         case 'class':
             $unit = new ClassObject();
             break;
     }
     $dom = new fDOMDocument();
     $dom->load($this->xmlDir . '/' . $indexNode->getAttribute('xml'));
     $unit->import($dom);
     return $unit;
 }