Skip to content

Commit

Permalink
Add directory collapsing code
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Jan 2, 2015
1 parent 1867dfb commit ebd7001
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/collector/project/SourceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getVanishedFiles() {
return $list;
}

public function export() {
public function export($collapse = false) {
if (count($this->collection) == 0) {
return $this->workDom;
}
Expand All @@ -150,10 +150,13 @@ public function export() {
}

$this->collection = array();

if ($collapse) {
$this->collapseDirectory();
}
return $this->workDom;
}


private function importDirNode(fDOMElement $dir, $path) {
$path .= $dir->getAttribute('name');
foreach($dir->query('phpdox:file') as $file) {
Expand All @@ -173,6 +176,20 @@ private function isChanged($path) {
return $org->getAttribute('sha1') != $new->getAttribute('sha1');
}

private function collapseDirectory() {
$first = $this->workDom->queryOne('/phpdox:source/phpdox:dir');
if ($first->query('phpdox:file')->length == 0 &&
$first->query('phpdox:dir')->length == 1) {
$dir = $first->queryOne('phpdox:dir');
foreach($dir->query('*') as $child) {
$first->appendChild($child);
}
$first->setAttribute('name', $first->getAttribute('name') . '/' . $dir->getAttribute('name'));
$first->removeChild($dir);
$this->collapseDirectory();
}
}

}


Expand Down

0 comments on commit ebd7001

Please sign in to comment.