PHP Class org\bovigo\vfs\vfsStream

Show file Open project: mikey179/vfsstream Class Usage Examples

Protected Properties

Property Type Description
$umask initial umask setting

Public Methods

Method Description
copyFromFileSystem ( string $path, vfsStreamDirectory $baseDir = null, integer $maxFileSize = 1048576 ) : vfsStreamDirectory copies the file system structure from given path into the base dir
create ( array $structure, vfsStreamDirectory $baseDir = null ) : vfsStreamDirectory creates vfsStream directory structure from an array and adds it to given base dir
disableDotfiles ( ) disable dotfiles in directory listings
enableDotfiles ( ) enable dotfiles in directory listings
getCurrentGroup ( ) : integer returns current group
getCurrentUser ( ) : integer returns current user
inspect ( org\bovigo\vfs\visitor\vfsStreamVisitor $visitor, org\bovigo\vfs\vfsStreamContent $content = null ) : org\bovigo\vfs\visitor\vfsStreamVisitor use visitor to inspect a content structure
newBlock ( string $name, integer $permissions = null ) : org\bovigo\vfs\vfsStreamBlock returns a new block with the given name
newDirectory ( string $name, integer $permissions = null ) : vfsStreamDirectory returns a new directory with given name
newFile ( string $name, integer $permissions = null ) : org\bovigo\vfs\vfsStreamFile returns a new file with given name
path ( string $url ) : string restores the path from the url
setQuota ( integer $bytes ) sets quota to given amount of bytes
setup ( string $rootDirName = 'root', integer $permissions = null, array $structure = [] ) : vfsStreamDirectory helper method for setting up vfsStream in unit tests
umask ( integer $umask = null ) : integer sets new umask setting and returns previous umask setting
url ( string $path ) : string prepends the scheme to the given URL
useDotfiles ( ) : boolean checks if vfsStream lists dotfiles in directory listings

Protected Methods

Method Description
addStructure ( array $structure, vfsStreamDirectory $baseDir ) : vfsStreamDirectory helper method to create subdirectories recursively

Method Details

addStructure() protected static method

helper method to create subdirectories recursively
protected static addStructure ( array $structure, vfsStreamDirectory $baseDir ) : vfsStreamDirectory
$structure array subdirectory structure to add
$baseDir vfsStreamDirectory directory to add the structure to
return vfsStreamDirectory

copyFromFileSystem() public static method

If no baseDir is given it will try to add the structure to the existing root directory without replacing existing childs except those with equal names. File permissions are copied as well. Please note that file contents will only be copied if their file size does not exceed the given $maxFileSize which defaults to 1024 KB. In case the file is larger file content will be mocked, see https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles.
See also: https://github.com/mikey179/vfsStream/issues/4
Since: 0.11.0
public static copyFromFileSystem ( string $path, vfsStreamDirectory $baseDir = null, integer $maxFileSize = 1048576 ) : vfsStreamDirectory
$path string path to copy the structure from
$baseDir vfsStreamDirectory directory to add the structure to
$maxFileSize integer maximum file size of files to copy content from
return vfsStreamDirectory

create() public static method

Assumed $structure contains an array like this: array('Core' = array('AbstractFactory' => array('test.php' => 'some text content', 'other.php' => 'Some more text content', 'Invalid.csv' => 'Something else', ), 'AnEmptyFolder' => array(), 'badlocation.php' => 'some bad content', ) ) the resulting directory tree will look like this:
baseDir
\- Core
 |- badlocation.php
 |- AbstractFactory
 | |- test.php
 | |- other.php
 | \- Invalid.csv
 \- AnEmptyFolder
Arrays will become directories with their key as directory name, and strings becomes files with their key as file name and their value as file content. If no baseDir is given it will try to add the structure to the existing root directory without replacing existing childs except those with equal names.
See also: https://github.com/mikey179/vfsStream/issues/14
See also: https://github.com/mikey179/vfsStream/issues/20
Since: 0.10.0
public static create ( array $structure, vfsStreamDirectory $baseDir = null ) : vfsStreamDirectory
$structure array directory structure to add under root directory
$baseDir vfsStreamDirectory base directory to add structure to
return vfsStreamDirectory

disableDotfiles() public static method

disable dotfiles in directory listings
Since: 1.3.0
public static disableDotfiles ( )

enableDotfiles() public static method

enable dotfiles in directory listings
Since: 1.3.0
public static enableDotfiles ( )

getCurrentGroup() public static method

If the system does not support posix_getgid() the current group will be root (0).
public static getCurrentGroup ( ) : integer
return integer

getCurrentUser() public static method

If the system does not support posix_getuid() the current user will be root (0).
public static getCurrentUser ( ) : integer
return integer

inspect() public static method

If the given content is null it will fall back to use the current root directory of the stream wrapper. Returns given visitor for method chaining comfort.
See also: https://github.com/mikey179/vfsStream/issues/10
Since: 0.10.0
public static inspect ( org\bovigo\vfs\visitor\vfsStreamVisitor $visitor, org\bovigo\vfs\vfsStreamContent $content = null ) : org\bovigo\vfs\visitor\vfsStreamVisitor
$visitor org\bovigo\vfs\visitor\vfsStreamVisitor the visitor who inspects
$content org\bovigo\vfs\vfsStreamContent directory structure to inspect
return org\bovigo\vfs\visitor\vfsStreamVisitor

newBlock() public static method

returns a new block with the given name
public static newBlock ( string $name, integer $permissions = null ) : org\bovigo\vfs\vfsStreamBlock
$name string name of the block device
$permissions integer permissions of block to create
return org\bovigo\vfs\vfsStreamBlock

newDirectory() public static method

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.
public static newDirectory ( string $name, integer $permissions = null ) : vfsStreamDirectory
$name string name of directory to create
$permissions integer permissions of directory to create
return vfsStreamDirectory

newFile() public static method

returns a new file with given name
public static newFile ( string $name, integer $permissions = null ) : org\bovigo\vfs\vfsStreamFile
$name string name of file to create
$permissions integer permissions of file to create
return org\bovigo\vfs\vfsStreamFile

path() public static method

restores the path from the url
public static path ( string $url ) : string
$url string vfsStream url to translate into path
return string

setQuota() public static method

sets quota to given amount of bytes
Since: 1.1.0
public static setQuota ( integer $bytes )
$bytes integer

setup() public static method

Instead of vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(vfsStream::newDirectory('root')); you can simply do vfsStream::setup() which yields the same result. Additionally, the method returns the freshly created root directory which you can use to make further adjustments to it. Assumed $structure contains an array like this: array('Core' = array('AbstractFactory' => array('test.php' => 'some text content', 'other.php' => 'Some more text content', 'Invalid.csv' => 'Something else', ), 'AnEmptyFolder' => array(), 'badlocation.php' => 'some bad content', ) ) the resulting directory tree will look like this:
root
\- Core
 |- badlocation.php
 |- AbstractFactory
 | |- test.php
 | |- other.php
 | \- Invalid.csv
 \- AnEmptyFolder
Arrays will become directories with their key as directory name, and strings becomes files with their key as file name and their value as file content.
See also: https://github.com/mikey179/vfsStream/issues/14
See also: https://github.com/mikey179/vfsStream/issues/20
Since: 0.7.0
public static setup ( string $rootDirName = 'root', integer $permissions = null, array $structure = [] ) : vfsStreamDirectory
$rootDirName string name of root directory
$permissions integer file permissions of root directory
$structure array directory structure to add under root directory
return vfsStreamDirectory

umask() public static method

If no value is given only the current umask setting is returned.
Since: 0.8.0
public static umask ( integer $umask = null ) : integer
$umask integer new umask setting
return integer

url() public static method

prepends the scheme to the given URL
public static url ( string $path ) : string
$path string path to translate to vfsStream url
return string

useDotfiles() public static method

checks if vfsStream lists dotfiles in directory listings
Since: 1.3.0
public static useDotfiles ( ) : boolean
return boolean

Property Details

$umask protected static property

initial umask setting
protected static $umask