\AppFile

A File class

Access and manage files Get contents of file

Summary

Methods
Properties
Constants
__construct()
ls()
getFiles()
getMessage()
delete()
load()
getContents()
No public properties found
No constants found
formatSize()
$path
$extensions
$files
$contents
$message
N/A
No private methods found
No private properties found
N/A

Properties

$path

$path : string

Store path of file or directory

Type

string

$extensions

$extensions : string

Store file extensions in regex format

Type

string

$files

$files : array

Store list of files

Type

array

$contents

$contents : string

Store contents of a file

Type

string

$message

$message : string

Store message

Type

string

Methods

__construct()

__construct(string  $path, string  $regex = '', array  $extensions = '') 

Set path of file or directory

Parameters

string $path

Path of file or directory

string $regex

Regex to limit file listing

array $extensions

Supported file extensions in regex format

ls()

ls() : boolean

List directory files Limit the files matching with regex pattern and file extensions

Returns

boolean —

Directory file listing successful or not

getFiles()

getFiles() : array

Get list of files after performing ls in a directory

Returns

array —

List of files of directory

getMessage()

getMessage() : string

Get message file operation message

Returns

string —

File operation message

delete()

delete() : \App\boll

Delete a file

Returns

\App\boll —

Deleting file successful or not

load()

load() : boolean

Load contents of a file

Returns

boolean —

Loading file contents success or not

getContents()

getContents() : string

Get contents of a file

Returns

string —

Contents of file

formatSize()

formatSize(integer  $bytes) : string

Format bytes to human readable file size

Parameters

integer $bytes

File size

Returns

string —

File size in human readable