third_party/vfsstream/vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php
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
- Api
Constants
Methods
copyFromFileSystem
(string $path,
\org\bovigo\vfs\vfsStreamDirectory
$baseDir = null, int $maxFileSize = 1048576)
:
\org\bovigo\vfs\vfsStreamDirectory
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.
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 |
Type | Description |
---|---|
\org\bovigo\vfs\vfsStreamDirectory |
Exception | Description |
---|---|
\InvalidArgumentException |
- See
- \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/4
- Since
- 0.11.0
create
(array $structure,
\org\bovigo\vfs\vfsStreamDirectory
$baseDir = null)
:
\org\bovigo\vfs\vfsStreamDirectory
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.
Name | Type | Description |
---|---|---|
$structure | array |
directory structure to add under root directory |
$baseDir | \org\bovigo\vfs\vfsStreamDirectory |
base directory to add structure to |
Type | Description |
---|---|
\org\bovigo\vfs\vfsStreamDirectory |
Exception | Description |
---|---|
\InvalidArgumentException |
- 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
getCurrentGroup
()
: int
returns current group
If the system does not support posix_getgid() the current group will be root (0).
Type | Description |
---|---|
int |
getCurrentUser
()
: int
returns current user
If the system does not support posix_getuid() the current user will be root (0).
Type | Description |
---|---|
int |
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
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.
Name | Type | Description |
---|---|---|
$visitor | \org\bovigo\vfs\visitor\vfsStreamVisitor |
the visitor who inspects |
$content | \org\bovigo\vfs\vfsStreamContent |
directory structure to inspect |
Type | Description |
---|---|
\org\bovigo\vfs\visitor\vfsStreamVisitor |
Exception | Description |
---|---|
\InvalidArgumentException |
- See
- \org\bovigo\vfs\https://github.com/mikey179/vfsStream/issues/10
- Since
- 0.10.0
newDirectory
(string $name, int $permissions = null)
:
\org\bovigo\vfs\vfsStreamDirectory
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.
Name | Type | Description |
---|---|---|
$name | string |
name of directory to create |
$permissions | int |
permissions of directory to create |
Type | Description |
---|---|
\org\bovigo\vfs\vfsStreamDirectory |
newFile
(string $name, int $permissions = null)
:
\org\bovigo\vfs\vfsStreamFile
returns a new file with given name
Name | Type | Description |
---|---|---|
$name | string |
name of file to create |
$permissions | int |
permissions of file to create |
Type | Description |
---|---|
\org\bovigo\vfs\vfsStreamFile |
path
(string $url)
: string
restores the path from the url
Name | Type | Description |
---|---|---|
$url | string |
vfsStream url to translate into path |
Type | Description |
---|---|
string |
setQuota
(int $bytes)
: void
sets quota to given amount of bytes
Name | Type | Description |
---|---|---|
$bytes | int |
- Since
- 1.1.0
setup
(string $rootDirName = 'root', int $permissions = null, array $structure = array())
:
\org\bovigo\vfs\vfsStreamDirectory
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.
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 |
Type | Description |
---|---|
\org\bovigo\vfs\vfsStreamDirectory |
- 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
umask
(int $umask = null)
: int
sets new umask setting and returns previous umask setting
If no value is given only the current umask setting is returned.
Name | Type | Description |
---|---|---|
$umask | int |
new umask setting |
Type | Description |
---|---|
int |
- Since
- 0.8.0