PHP Class luya\helpers\FileHelper

Author: Basil Suter ([email protected])
Inheritance: extends yii\helpers\BaseFileHelper
Afficher le fichier Open project: zephir/luya Class Usage Examples

Méthodes publiques

Méthode Description
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.

Method Details

ensureExtension() public static méthode

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
Résultat the ensured file/path with extension

getFileContent() public static méthode

Basic helper to retreive the content of a file and catched exception. The filename will auto alias encode by Yii::getAlias function.
Since: 1.0.0-beta7
public static getFileContent ( string $fileName ) : string | boolean
$fileName string The path to the file to get the content
Résultat string | boolean

getFileHash() public static méthode

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
Résultat false | string Returns false or the md5 hash of this file

getFileInfo() public static méthode

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
Résultat object With extension and name keys.

humanReadableFilesize() public static méthode

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
Résultat string The readable size definition

writeFile() public static méthode

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
Résultat boolean