You are here

protected static function vfsStream::addStructure in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php \org\bovigo\vfs\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

vfsStreamDirectory

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 221

Class

vfsStream
Some utility methods for vfsStream.

Namespace

org\bovigo\vfs

Code

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);
      }
    }
  }
  return $baseDir;
}