\rex_file

Class for handling files.

Summary

Methods
Properties
Constants
require()
get()
getConfig()
getCache()
put()
putConfig()
putCache()
copy()
move()
delete()
extension()
mimeType()
formattedSize()
getOutput()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

require()

require(string  $file) : string

Returns the content of a file.

Parameters

string $file

Path to the file

Throws

\rex_exception

throws when the file cannot be read

Returns

string —

Content of the file

get()

get(string  $file, mixed  $default = null) : mixed

Returns the content of a file.

Parameters

string $file

Path to the file

mixed $default

Default value

Returns

mixed —

Content of the file or default value if the file isn't readable

getConfig()

getConfig(string  $file, mixed  $default = []) : mixed

Returns the content of a config file.

Parameters

string $file

Path to the file

mixed $default

Default value

Returns

mixed —

Content of the file or default value if the file isn't readable

getCache()

getCache(string  $file, mixed  $default = []) : mixed

Returns the content of a cache file.

Parameters

string $file

Path to the file

mixed $default

Default value

Returns

mixed —

Content of the file or default value if the file isn't readable

put()

put(string  $file, string  $content) : bool

Puts content in a file.

Parameters

string $file

Path to the file

string $content

Content for the file

Returns

bool —

TRUE on success, FALSE on failure

putConfig()

putConfig(string  $file, mixed  $content, int  $inline = 3) : bool

Puts content in a config file.

Parameters

string $file

Path to the file

mixed $content

Content for the file

int $inline

The level where you switch to inline YAML

Returns

bool —

TRUE on success, FALSE on failure

putCache()

putCache(string  $file, mixed  $content) : bool

Puts content in a cache file.

Parameters

string $file

Path to the file

mixed $content

Content for the file

Returns

bool —

TRUE on success, FALSE on failure

copy()

copy(string  $srcfile, string  $dstfile) : bool

Copies a file.

Parameters

string $srcfile

Path of the source file

string $dstfile

Path of the destination file or directory

Returns

bool —

TRUE on success, FALSE on failure

move()

move(string  $srcfile, string  $dstfile) : bool

Renames a file.

Parameters

string $srcfile

Path of the source file

string $dstfile

Path of the destination file or directory

Returns

bool —

TRUE on success, FALSE on failure

delete()

delete(string  $file) : bool

Deletes a file.

Parameters

string $file

Path of the file

Returns

bool —

TRUE on success, FALSE on failure

extension()

extension(string  $filename) : string

Extracts the extension of the given filename.

Parameters

string $filename

Filename

Returns

string —

Extension of $filename

mimeType()

mimeType(string  $file) : null|string

Detects the mime type of the given file.

Parameters

string $file

Path to the file

Returns

null|string —

Mime type or null if the type could not be detected

formattedSize()

formattedSize(string  $file, array  $format = []) : string

Formates the filesize of the given file into a userfriendly form.

Parameters

string $file

Path to the file

array $format

Returns

string —

Formatted filesize

getOutput()

getOutput(string  $file) : string

Gets executed content of given file.

Parameters

string $file

Path of the file

Returns

string —

executed Content