PHP Class File, someline-starter

Show file Open project: someline/someline-starter Class Usage Examples

Public Methods

Method Description
allFiles ( string $directory, boolean $hidden = false ) : array Get all of the files from the given directory (recursive).
append ( string $path, string $data ) : integer Append to a file.
basename ( string $path ) : string Extract the trailing name component from a file path.
cleanDirectory ( string $directory ) : boolean Empty the specified directory of all files and folders.
copy ( string $path, string $target ) : boolean Copy a file to a new location.
copyDirectory ( string $directory, string $destination, integer $options = null ) : boolean Copy a directory from one location to another.
delete ( string | array $paths ) : boolean Delete the file at a given path.
deleteDirectory ( string $directory, boolean $preserve = false ) : boolean Recursively delete a directory.
directories ( string $directory ) : array Get all of the directories within a given directory.
dirname ( string $path ) : string Extract the parent directory from a file path.
exists ( string $path ) : boolean Determine if a file or directory exists.
extension ( string $path ) : string Extract the file extension from a file path.
files ( string $directory ) : array Get an array of all files in a directory.
get ( string $path, boolean $lock = false ) : string Get the contents of a file.
getRequire ( string $path ) : mixed Get the returned value of a file.
glob ( string $pattern, integer $flags ) : array Find path names matching a given pattern.
hasMacro ( string $name ) : boolean Checks if macro is registered.
isDirectory ( string $directory ) : boolean Determine if the given path is a directory.
isFile ( string $file ) : boolean Determine if the given path is a file.
isWritable ( string $path ) : boolean Determine if the given path is writable.
lastModified ( string $path ) : integer Get the file's last modification time.
macro ( string $name, callable $macro ) : void Register a custom macro.
makeDirectory ( string $path, integer $mode = 493, boolean $recursive = false, boolean $force = false ) : boolean Create a directory.
mimeType ( string $path ) : string | false Get the mime-type of a given file.
move ( string $path, string $target ) : boolean Move a file to a new location.
moveDirectory ( string $from, string $to, boolean $overwrite = false ) : boolean Move a directory.
name ( string $path ) : string Extract the file name from a file path.
prepend ( string $path, string $data ) : integer Prepend to a file.
put ( string $path, string $contents, boolean $lock = false ) : integer Write the contents of a file.
requireOnce ( string $file ) : mixed Require the given file once.
sharedGet ( string $path ) : string Get contents of a file with shared access.
size ( string $path ) : integer Get the file size of a given file.
type ( string $path ) : string Get the file type of a given file.

Method Details

allFiles() public static method

Get all of the files from the given directory (recursive).
public static allFiles ( string $directory, boolean $hidden = false ) : array
$directory string
$hidden boolean
return array

append() public static method

Append to a file.
public static append ( string $path, string $data ) : integer
$path string
$data string
return integer

basename() public static method

Extract the trailing name component from a file path.
public static basename ( string $path ) : string
$path string
return string

cleanDirectory() public static method

Empty the specified directory of all files and folders.
public static cleanDirectory ( string $directory ) : boolean
$directory string
return boolean

copy() public static method

Copy a file to a new location.
public static copy ( string $path, string $target ) : boolean
$path string
$target string
return boolean

copyDirectory() public static method

Copy a directory from one location to another.
public static copyDirectory ( string $directory, string $destination, integer $options = null ) : boolean
$directory string
$destination string
$options integer
return boolean

delete() public static method

Delete the file at a given path.
public static delete ( string | array $paths ) : boolean
$paths string | array
return boolean

deleteDirectory() public static method

The directory itself may be optionally preserved.
public static deleteDirectory ( string $directory, boolean $preserve = false ) : boolean
$directory string
$preserve boolean
return boolean

directories() public static method

Get all of the directories within a given directory.
public static directories ( string $directory ) : array
$directory string
return array

dirname() public static method

Extract the parent directory from a file path.
public static dirname ( string $path ) : string
$path string
return string

exists() public static method

Determine if a file or directory exists.
public static exists ( string $path ) : boolean
$path string
return boolean

extension() public static method

Extract the file extension from a file path.
public static extension ( string $path ) : string
$path string
return string

files() public static method

Get an array of all files in a directory.
public static files ( string $directory ) : array
$directory string
return array

get() public static method

Get the contents of a file.
public static get ( string $path, boolean $lock = false ) : string
$path string
$lock boolean
return string

getRequire() public static method

Get the returned value of a file.
public static getRequire ( string $path ) : mixed
$path string
return mixed

glob() public static method

Find path names matching a given pattern.
public static glob ( string $pattern, integer $flags ) : array
$pattern string
$flags integer
return array

hasMacro() public static method

Checks if macro is registered.
public static hasMacro ( string $name ) : boolean
$name string
return boolean

isDirectory() public static method

Determine if the given path is a directory.
public static isDirectory ( string $directory ) : boolean
$directory string
return boolean

isFile() public static method

Determine if the given path is a file.
public static isFile ( string $file ) : boolean
$file string
return boolean

isWritable() public static method

Determine if the given path is writable.
public static isWritable ( string $path ) : boolean
$path string
return boolean

lastModified() public static method

Get the file's last modification time.
public static lastModified ( string $path ) : integer
$path string
return integer

macro() public static method

Register a custom macro.
public static macro ( string $name, callable $macro ) : void
$name string
$macro callable
return void

makeDirectory() public static method

Create a directory.
public static makeDirectory ( string $path, integer $mode = 493, boolean $recursive = false, boolean $force = false ) : boolean
$path string
$mode integer
$recursive boolean
$force boolean
return boolean

mimeType() public static method

Get the mime-type of a given file.
public static mimeType ( string $path ) : string | false
$path string
return string | false

move() public static method

Move a file to a new location.
public static move ( string $path, string $target ) : boolean
$path string
$target string
return boolean

moveDirectory() public static method

Move a directory.
public static moveDirectory ( string $from, string $to, boolean $overwrite = false ) : boolean
$from string
$to string
$overwrite boolean
return boolean

name() public static method

Extract the file name from a file path.
public static name ( string $path ) : string
$path string
return string

prepend() public static method

Prepend to a file.
public static prepend ( string $path, string $data ) : integer
$path string
$data string
return integer

put() public static method

Write the contents of a file.
public static put ( string $path, string $contents, boolean $lock = false ) : integer
$path string
$contents string
$lock boolean
return integer

requireOnce() public static method

Require the given file once.
public static requireOnce ( string $file ) : mixed
$file string
return mixed

sharedGet() public static method

Get contents of a file with shared access.
public static sharedGet ( string $path ) : string
$path string
return string

size() public static method

Get the file size of a given file.
public static size ( string $path ) : integer
$path string
return integer

type() public static method

Get the file type of a given file.
public static type ( string $path ) : string
$path string
return string