PHP Class Ouzo\Utilities\Files

Afficher le fichier Open project: letsdrink/ouzo Class Usage Examples

Méthodes publiques

Méthode Description
convertUnitFileSize ( integer $size ) : string Converts file size in bytes to a string with unit.
copyContent ( string $inputFile, string $outputFile, integer $bufferSize = 1024 ) Copies content from $inputFile to $outputFile.
delete ( string $path ) : boolean Deletes file, throws FileNotFoundException if the file does not exist.
deleteIfExists ( $path ) : boolean Deletes file if exists, otherwise return false if the file does not exist.
exists ( string $path ) : boolean Checks if the given file exists.
getFilesRecursivelyWithSpecifiedExtension ( string $dir, string $extension ) : array Returns all files from the given directory that have the given extension.
load ( string $path, boolean $loadOnce = true ) Loads a file using require or require_once if the $loadOnce flag is set to true, if the file does not exist, throws FileNotFoundException.
loadIfExists ( string $path, boolean $loadOnce = true ) : boolean Loads a file using require or require_once if the $loadOnce flag is set to true.
mimeType ( string $path ) : string Returns mime type for the given file path.
move ( string $sourcePath, string $destinationPath ) : boolean Moves file from the source to the destination, throws FileNotFoundException if the source directory does not exist.
size ( string $path ) : integer Returns a size of the given file.

Private Methods

Méthode Description
_require ( $path, $loadOnce )

Method Details

convertUnitFileSize() public static méthode

Example: $unit = Files::convertUnitFileSize(146432); Result: 143 KB
public static convertUnitFileSize ( integer $size ) : string
$size integer
Résultat string

copyContent() public static méthode

Copies content from $inputFile to $outputFile.
public static copyContent ( string $inputFile, string $outputFile, integer $bufferSize = 1024 )
$inputFile string
$outputFile string
$bufferSize integer

delete() public static méthode

Deletes file, throws FileNotFoundException if the file does not exist.
public static delete ( string $path ) : boolean
$path string
Résultat boolean

deleteIfExists() public static méthode

Deletes file if exists, otherwise return false if the file does not exist.
public static deleteIfExists ( $path ) : boolean
$path
Résultat boolean

exists() public static méthode

Checks if the given file exists.
public static exists ( string $path ) : boolean
$path string
Résultat boolean

getFilesRecursivelyWithSpecifiedExtension() public static méthode

Returns all files from the given directory that have the given extension.
public static getFilesRecursivelyWithSpecifiedExtension ( string $dir, string $extension ) : array
$dir string
$extension string
Résultat array

load() public static méthode

Loads a file using require or require_once if the $loadOnce flag is set to true, if the file does not exist, throws FileNotFoundException.
public static load ( string $path, boolean $loadOnce = true )
$path string
$loadOnce boolean

loadIfExists() public static méthode

Loads a file using require or require_once if the $loadOnce flag is set to true.
public static loadIfExists ( string $path, boolean $loadOnce = true ) : boolean
$path string
$loadOnce boolean
Résultat boolean

mimeType() public static méthode

Returns mime type for the given file path.
public static mimeType ( string $path ) : string
$path string
Résultat string

move() public static méthode

Moves file from the source to the destination, throws FileNotFoundException if the source directory does not exist.
public static move ( string $sourcePath, string $destinationPath ) : boolean
$sourcePath string
$destinationPath string
Résultat boolean

size() public static méthode

Returns a size of the given file.
public static size ( string $path ) : integer
$path string
Résultat integer