PHP Класс Ouzo\Utilities\Files

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
_require ( $path, $loadOnce )

Описание методов

convertUnitFileSize() публичный статический Метод

Example: $unit = Files::convertUnitFileSize(146432); Result: 143 KB
public static convertUnitFileSize ( integer $size ) : string
$size integer
Результат string

copyContent() публичный статический Метод

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

delete() публичный статический Метод

Deletes file, throws FileNotFoundException if the file does not exist.
public static delete ( string $path ) : boolean
$path string
Результат boolean

deleteIfExists() публичный статический Метод

Deletes file if exists, otherwise return false if the file does not exist.
public static deleteIfExists ( $path ) : boolean
$path
Результат boolean

exists() публичный статический Метод

Checks if the given file exists.
public static exists ( string $path ) : boolean
$path string
Результат boolean

getFilesRecursivelyWithSpecifiedExtension() публичный статический Метод

Returns all files from the given directory that have the given extension.
public static getFilesRecursivelyWithSpecifiedExtension ( string $dir, string $extension ) : array
$dir string
$extension string
Результат array

load() публичный статический Метод

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() публичный статический Метод

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
Результат boolean

mimeType() публичный статический Метод

Returns mime type for the given file path.
public static mimeType ( string $path ) : string
$path string
Результат string

move() публичный статический Метод

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
Результат boolean

size() публичный статический Метод

Returns a size of the given file.
public static size ( string $path ) : integer
$path string
Результат integer