You are here

public static function vfsStream::newDirectory 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::newDirectory()

returns a new directory with given name

If the name contains slashes, a new directory structure will be created. The returned directory will always be the parent directory of this directory structure.

Parameters

string $name name of directory to create:

int $permissions permissions of directory to create:

Return value

vfsStreamDirectory

13 calls to vfsStream::newDirectory()
vfsStream::setup in vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php
helper method for setting up vfsStream in unit tests
vfsStreamDirectoryIssue18TestCase::setUp in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php
set up test environment
vfsStreamPrintVisitorTestCase::visitDirectoryWritesDirectoryNameToStream in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php
@test
vfsStreamTestCase::copyFromEmptyFolder in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php
@test @group issue_4 @since 0.11.0
vfsStreamTestCase::copyFromWithSubFolders in vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php
@test @group issue_4 @since 0.11.0

... See full list

File

vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php, line 338

Class

vfsStream
Some utility methods for vfsStream.

Namespace

org\bovigo\vfs

Code

public static function newDirectory($name, $permissions = null) {
  if ('/' === $name[0]) {
    $name = substr($name, 1);
  }
  $firstSlash = strpos($name, '/');
  if (false === $firstSlash) {
    return new vfsStreamDirectory($name, $permissions);
  }
  $ownName = substr($name, 0, $firstSlash);
  $subDirs = substr($name, $firstSlash + 1);
  $directory = new vfsStreamDirectory($ownName, $permissions);
  self::newDirectory($subDirs, $permissions)
    ->at($directory);
  return $directory;
}