Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



third_party/vfsstream/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php

Table of Contents
This file is part of vfsStream.

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Package
org\bovigo\vfs

\org\bovigo\vfs\vfsStream

Package: Default
Some utility methods for vfsStream.
Api

Constants

> V Constant SCHEME = 'vfs'
url scheme
> V Constant OWNER_ROOT = 0
owner: root
> V Constant OWNER_USER_1 = 1
owner: user 1
> V Constant OWNER_USER_2 = 2
owner: user 2
> V Constant GROUP_ROOT = 0
group: root
> V Constant GROUP_USER_1 = 1
group: user 1
> V Constant GROUP_USER_2 = 2
group: user 2

Methods

method public copyFromFileSystem (string $path, \org\bovigo\vfs\vfsStreamDirectory $baseDir = null, int $maxFileSize = 1048576) : \org\bovigo\vfs\vfsStreamDirectory
static

copies the file system structure from given path into the base dir

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 is 1024 KB.

Parameters
Name Type Description
$path string

path to copy the structure from

$baseDir \org\bovigo\vfs\vfsStreamDirectory

directory to add the structure to

$maxFileSize int

maximum file size of files to copy content from

Returns
Type Description
\org\bovigo\vfs\vfsStreamDirectory
Throws
Exception Description
\InvalidArgumentException
Details
See
\org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/4
Since
0.11.0
method public create (array $structure, \org\bovigo\vfs\vfsStreamDirectory $baseDir = null) : \org\bovigo\vfs\vfsStreamDirectory
static

creates vfsStream directory structure from an array and adds it to given base dir

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.

Parameters
Name Type Description
$structure array

directory structure to add under root directory

$baseDir \org\bovigo\vfs\vfsStreamDirectory

base directory to add structure to

Returns
Type Description
\org\bovigo\vfs\vfsStreamDirectory
Throws
Exception Description
\InvalidArgumentException
Details
See
\org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/14
See
\org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/20
Since
0.10.0
method public getCurrentGroup () : int
static

returns current group

If the system does not support posix_getgid() the current group will be root (0).

Returns
Type Description
int
method public getCurrentUser () : int
static

returns current user

If the system does not support posix_getuid() the current user will be root (0).

Returns
Type Description
int
method public inspect ( \org\bovigo\vfs\visitor\vfsStreamVisitor $visitor, \org\bovigo\vfs\vfsStreamContent $content = null) : \org\bovigo\vfs\visitor\vfsStreamVisitor
static

use visitor to inspect a content structure

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.

Parameters
Name Type Description
$visitor \org\bovigo\vfs\visitor\vfsStreamVisitor

the visitor who inspects

$content \org\bovigo\vfs\vfsStreamContent

directory structure to inspect

Returns
Type Description
\org\bovigo\vfs\visitor\vfsStreamVisitor
Throws
Exception Description
\InvalidArgumentException
Details
See
\org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/10
Since
0.10.0
method public newDirectory (string $name, int $permissions = null) : \org\bovigo\vfs\vfsStreamDirectory
static

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
Name Type Description
$name string

name of directory to create

$permissions int

permissions of directory to create

Returns
Type Description
\org\bovigo\vfs\vfsStreamDirectory
method public newFile (string $name, int $permissions = null) : \org\bovigo\vfs\vfsStreamFile
static

returns a new file with given name

Parameters
Name Type Description
$name string

name of file to create

$permissions int

permissions of file to create

Returns
Type Description
\org\bovigo\vfs\vfsStreamFile
method public path (string $url) : string
static

restores the path from the url

Parameters
Name Type Description
$url string

vfsStream url to translate into path

Returns
Type Description
string
method public setQuota (int $bytes) : void
static

sets quota to given amount of bytes

Parameters
Name Type Description
$bytes int
Details
Since
1.1.0
method public setup (string $rootDirName = 'root', int $permissions = null, array $structure = array()) : \org\bovigo\vfs\vfsStreamDirectory
static

helper method for setting up vfsStream in unit tests

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.

Parameters
Name Type Description
$rootDirName string

name of root directory

$permissions int

file permissions of root directory

$structure array

directory structure to add under root directory

Returns
Type Description
\org\bovigo\vfs\vfsStreamDirectory
Details
See
\org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/14
See
\org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/20
Since
0.7.0
method public umask (int $umask = null) : int
static

sets new umask setting and returns previous umask setting

If no value is given only the current umask setting is returned.

Parameters
Name Type Description
$umask int

new umask setting

Returns
Type Description
int
Details
Since
0.8.0
method public url (string $path) : string
static

prepends the scheme to the given URL

Parameters
Name Type Description
$path string

path to translate to vfsStream url

Returns
Type Description
string
Documentation was generated by phpDocumentor 2.0.0a12 .