Dir
in package
implements
ArrayAccess, Countable, IteratorAggregate
Directory class
Tags
Table of Contents
Interfaces
- ArrayAccess
- Countable
- IteratorAggregate
Properties
- $absolute : bool
- Flag to store the absolute path.
- $files : array<string|int, mixed>
- The files within the directory
- $filesOnly : bool
- Flag to include only files and no directories
- $path : string|null
- The directory path
- $recursive : bool
- Flag to dig recursively.
- $relative : bool
- Flag to store the relative path.
- $tree : array<string|int, mixed>
- The nested tree map of the directory and its files
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a file
- __isset() : bool
- Does file exist
- __set() : void
- Set method
- __unset() : void
- Unset method
- copyTo() : void
- Copy an entire directory recursively to another destination directory
- count() : int
- Method to get the count of files in the directory
- deleteFile() : void
- Delete a file
- emptyDir() : void
- Empty an entire directory
- fileExists() : bool
- File exists
- getFiles() : array<string|int, mixed>
- Get the files
- getIterator() : ArrayIterator
- Method to iterate over the files
- getPath() : string|null
- Get the path
- getTree() : array<string|int, mixed>
- Get the tree
- isAbsolute() : bool
- Is absolute
- isFilesOnly() : bool
- Is files only
- isRecursive() : bool
- Is recursive
- isRelative() : bool
- Is relative
- offsetExists() : bool
- ArrayAccess offsetExists
- offsetGet() : mixed
- ArrayAccess offsetGet
- offsetSet() : void
- ArrayAccess offsetSet
- offsetUnset() : void
- ArrayAccess offsetUnset
- setAbsolute() : Dir
- Set absolute
- setFilesOnly() : Dir
- Set files only
- setRecursive() : Dir
- Set recursive
- setRelative() : Dir
- Set relative
- buildTree() : array<string|int, mixed>
- Build the directory tree
- traverse() : void
- Traverse the directory
- traverseRecursively() : void
- Traverse the directory recursively
Properties
$absolute
Flag to store the absolute path.
protected
bool
$absolute
= false
$files
The files within the directory
protected
array<string|int, mixed>
$files
= []
$filesOnly
Flag to include only files and no directories
protected
bool
$filesOnly
= false
$path
The directory path
protected
string|null
$path
= null
$recursive
Flag to dig recursively.
protected
bool
$recursive
= false
$relative
Flag to store the relative path.
protected
bool
$relative
= false
$tree
The nested tree map of the directory and its files
protected
array<string|int, mixed>
$tree
= []
Methods
__construct()
Constructor
public
__construct(string $dir[, array<string|int, mixed> $options = [] ]) : mixed
Instantiate a directory object
Parameters
- $dir : string
- $options : array<string|int, mixed> = []
Tags
__get()
Get a file
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Does file exist
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__set()
Set method
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
Tags
__unset()
Unset method
public
__unset(string $name) : void
Parameters
- $name : string
Tags
copyTo()
Copy an entire directory recursively to another destination directory
public
copyTo(string $destination[, bool $full = true ]) : void
Parameters
- $destination : string
- $full : bool = true
count()
Method to get the count of files in the directory
public
count() : int
Return values
intdeleteFile()
Delete a file
public
deleteFile(string $file) : void
Parameters
- $file : string
Tags
emptyDir()
Empty an entire directory
public
emptyDir([bool $remove = false ][, string|null $path = null ]) : void
Parameters
- $remove : bool = false
- $path : string|null = null
Tags
fileExists()
File exists
public
fileExists(string $file) : bool
Parameters
- $file : string
Return values
boolgetFiles()
Get the files
public
getFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>getIterator()
Method to iterate over the files
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetPath()
Get the path
public
getPath() : string|null
Return values
string|nullgetTree()
Get the tree
public
getTree() : array<string|int, mixed>
Return values
array<string|int, mixed>isAbsolute()
Is absolute
public
isAbsolute() : bool
Return values
boolisFilesOnly()
Is files only
public
isFilesOnly() : bool
Return values
boolisRecursive()
Is recursive
public
isRecursive() : bool
Return values
boolisRelative()
Is relative
public
isRelative() : bool
Return values
booloffsetExists()
ArrayAccess offsetExists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
ArrayAccess offsetGet
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
ArrayAccess offsetSet
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
ArrayAccess offsetUnset
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
Tags
setAbsolute()
Set absolute
public
setAbsolute(bool $absolute) : Dir
Parameters
- $absolute : bool
Return values
DirsetFilesOnly()
Set files only
public
setFilesOnly(bool $filesOnly) : Dir
Parameters
- $filesOnly : bool
Return values
DirsetRecursive()
Set recursive
public
setRecursive(bool $recursive) : Dir
Parameters
- $recursive : bool
Return values
DirsetRelative()
Set relative
public
setRelative(bool $relative) : Dir
Parameters
- $relative : bool
Return values
DirbuildTree()
Build the directory tree
protected
buildTree(DirectoryIterator $it) : array<string|int, mixed>
Parameters
- $it : DirectoryIterator
Return values
array<string|int, mixed>traverse()
Traverse the directory
protected
traverse() : void
traverseRecursively()
Traverse the directory recursively
protected
traverseRecursively() : void