X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fmikey179%2FvfsStream%2Fsrc%2Fmain%2Fphp%2Forg%2Fbovigo%2Fvfs%2Fvisitor%2FvfsStreamStructureVisitor.php;fp=vendor%2Fmikey179%2FvfsStream%2Fsrc%2Fmain%2Fphp%2Forg%2Fbovigo%2Fvfs%2Fvisitor%2FvfsStreamStructureVisitor.php;h=47acc45cd8bcca22ffc3ed1be5aa79e64e5b1467;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php b/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php new file mode 100644 index 000000000..47acc45cd --- /dev/null +++ b/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php @@ -0,0 +1,111 @@ +reset(); + } + + /** + * visit a file and process it + * + * @param vfsStreamFile $file + * @return vfsStreamStructureVisitor + */ + public function visitFile(vfsStreamFile $file) + { + $this->current[$file->getName()] = $file->getContent(); + return $this; + } + + /** + * visit a block device and process it + * + * @param vfsStreamBlock $block + * @return vfsStreamStructureVisitor + */ + public function visitBlockDevice(vfsStreamBlock $block) + { + $this->current['[' . $block->getName() . ']'] = $block->getContent(); + return $this; + } + + /** + * visit a directory and process it + * + * @param vfsStreamDirectory $dir + * @return vfsStreamStructureVisitor + */ + public function visitDirectory(vfsStreamDirectory $dir) + { + $this->current[$dir->getName()] = array(); + $tmp =& $this->current; + $this->current =& $tmp[$dir->getName()]; + foreach ($dir as $child) { + $this->visit($child); + } + + $this->current =& $tmp; + return $this; + } + + /** + * returns structure of visited contents + * + * @return array + * @api + */ + public function getStructure() + { + return $this->structure; + } + + /** + * resets structure so visitor could be reused + * + * @return vfsStreamStructureVisitor + */ + public function reset() + { + $this->structure = array(); + $this->current =& $this->structure; + return $this; + } +}