PHP Класс luya\helpers\FileHelper

Автор: Basil Suter ([email protected])
Наследование: extends yii\helpers\BaseFileHelper
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
ensureExtension ( string $file, string $extension ) : the Append a file extension to a path/file if there is no or an empty extension provided, this helper methods is used to make sure the right extension existing on files.
getFileContent ( string $fileName ) : string | boolean Basic helper to retreive the content of a file and catched exception. The filename will auto alias encode by Yii::getAlias function.
getFileHash ( string $sourceFile ) : false | string Generate a md5 hash of a file. This is eqauls to md5sum command
getFileInfo ( string $sourceFile ) : object Get extension and name from a file for the provided source/path of the file.
humanReadableFilesize ( integer $size ) : string Generate a human readable size informations from provided Byte/s size
writeFile ( string $fileName, string $content ) : boolean Basic helper method to write files with exception capture. The fileName will auto wrapped trough the Yii::getAlias function.

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

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

Append a file extension to a path/file if there is no or an empty extension provided, this helper methods is used to make sure the right extension existing on files.
public static ensureExtension ( string $file, string $extension ) : the
$file string The file where extension should be append if not existing
$extension string
Результат the ensured file/path with extension

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

Basic helper to retreive the content of a file and catched exception. The filename will auto alias encode by Yii::getAlias function.
С версии: 1.0.0-beta7
public static getFileContent ( string $fileName ) : string | boolean
$fileName string The path to the file to get the content
Результат string | boolean

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

Generate a md5 hash of a file. This is eqauls to md5sum command
public static getFileHash ( string $sourceFile ) : false | string
$sourceFile string The path to the file
Результат false | string Returns false or the md5 hash of this file

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

Get extension and name from a file for the provided source/path of the file.
public static getFileInfo ( string $sourceFile ) : object
$sourceFile string The path of the file
Результат object With extension and name keys.

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

Generate a human readable size informations from provided Byte/s size
public static humanReadableFilesize ( integer $size ) : string
$size integer The size to convert in Byte
Результат string The readable size definition

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

Basic helper method to write files with exception capture. The fileName will auto wrapped trough the Yii::getAlias function.
public static writeFile ( string $fileName, string $content ) : boolean
$fileName string The path to the file with file name
$content string The content to store in this File
Результат boolean