function vfsStream::addStructure
helper method to create subdirectories recursively
Parameters
array $structure subdirectory structure to add:
vfsStreamDirectory $baseDir directory to add the structure to:
Return value
1 call to vfsStream::addStructure()
- vfsStream::create in vendor/
mikey179/ vfsstream/ src/ main/ php/ org/ bovigo/ vfs/ vfsStream.php - creates vfsStream directory structure from an array and adds it to given base dir
File
-
vendor/
mikey179/ vfsstream/ src/ main/ php/ org/ bovigo/ vfs/ vfsStream.php, line 231
Class
- vfsStream
- Some utility methods for vfsStream.
Namespace
org\bovigo\vfsCode
protected static function addStructure(array $structure, vfsStreamDirectory $baseDir) {
foreach ($structure as $name => $data) {
$name = (string) $name;
if (is_array($data) === true) {
self::addStructure($data, self::newDirectory($name)->at($baseDir));
}
elseif (is_string($data) === true) {
$matches = null;
preg_match('/^\\[(.*)\\]$/', $name, $matches);
if ($matches !== array()) {
self::newBlock($matches[1])->withContent($data)
->at($baseDir);
}
else {
self::newFile($name)->withContent($data)
->at($baseDir);
}
}
elseif ($data instanceof FileContent) {
self::newFile($name)->withContent($data)
->at($baseDir);
}
elseif ($data instanceof vfsStreamFile) {
$baseDir->addChild($data);
}
}
return $baseDir;
}