Documentation

rex_file
in package

Class for handling files.

Table of Contents

Methods

append()  : bool
Appends content to a file.
copy()  : bool
Copies a file.
delete()  : bool
Deletes a file.
extension()  : string
Extracts the extension of the given filename.
formattedSize()  : string
Formates the filesize of the given file into a userfriendly form.
get()  : string|T
Returns the content of a file.
getCache()  : array<string|int, mixed>|T
Returns the content of a cache file.
getConfig()  : array<string|int, mixed>|T
Returns the content of a config file.
getOutput()  : string
Gets executed content of given file.
mimeType()  : string|null
Detects the mime type of the given file.
move()  : bool
Renames a file.
put()  : bool
Puts content in a file.
putCache()  : bool
Puts content in a cache file.
putConfig()  : bool
Puts content in a config file.
require()  : string
Returns the content of a file.

Methods

append()

Appends content to a file.

public static append(string $file, string $content[, string $delimiter = '' ]) : bool
Parameters
$file : string

Path to the file

$content : string

Content for the file

$delimiter : string = ''

delimiter for new Content

Tags
psalm-assert-if-true

=non-empty-string $file

Return values
bool

TRUE on success, FALSE on failure

copy()

Copies a file.

public static copy(string $srcfile, string $dstfile) : bool
Parameters
$srcfile : string

Path of the source file

$dstfile : string

Path of the destination file or directory

Tags
psalm-assert-if-true

=non-empty-string $srcfile

psalm-assert-if-true

=non-empty-string $dstfile

Return values
bool

TRUE on success, FALSE on failure

delete()

Deletes a file.

public static delete(string $file) : bool
Parameters
$file : string

Path of the file

Return values
bool

TRUE on success, FALSE on failure

extension()

Extracts the extension of the given filename.

public static extension(string $filename) : string
Parameters
$filename : string

Filename

Tags
psalm-assert-if-true

=non-empty-string $filename

Return values
string

Extension of $filename

formattedSize()

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

public static formattedSize(string $file[, array<string|int, mixed> $format = [] ]) : string
Parameters
$file : string

Path to the file

$format : array<string|int, mixed> = []
Return values
string

Formatted filesize

get()

Returns the content of a file.

public static get(string $file[, T $default = null ]) : string|T
Parameters
$file : string

Path to the file

$default : T = null

Default value

Tags
template

T

Return values
string|T

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

getCache()

Returns the content of a cache file.

public static getCache(string $file[, T $default = [] ]) : array<string|int, mixed>|T
Parameters
$file : string

Path to the file

$default : T = []

Default value

Tags
template

T

Return values
array<string|int, mixed>|T

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

getConfig()

Returns the content of a config file.

public static getConfig(string $file[, T $default = [] ]) : array<string|int, mixed>|T
Parameters
$file : string

Path to the file

$default : T = []

Default value

Tags
template

T

Return values
array<string|int, mixed>|T

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

getOutput()

Gets executed content of given file.

public static getOutput(string $file) : string
Parameters
$file : string

Path of the file

Return values
string

executed Content

mimeType()

Detects the mime type of the given file.

public static mimeType(string $file) : string|null
Parameters
$file : string

Path to the file

Return values
string|null

Mime type or null if the type could not be detected

move()

Renames a file.

public static move(string $srcfile, string $dstfile) : bool
Parameters
$srcfile : string

Path of the source file

$dstfile : string

Path of the destination file or directory

Tags
psalm-assert-if-true

=non-empty-string $srcfile

psalm-assert-if-true

=non-empty-string $dstfile

Return values
bool

TRUE on success, FALSE on failure

put()

Puts content in a file.

public static put(string $file, string $content) : bool
Parameters
$file : string

Path to the file

$content : string

Content for the file

Tags
psalm-assert-if-true

=non-empty-string $file

Return values
bool

TRUE on success, FALSE on failure

putCache()

Puts content in a cache file.

public static putCache(string $file, array<string|int, mixed> $content) : bool
Parameters
$file : string

Path to the file

$content : array<string|int, mixed>

Content for the file

Tags
psalm-assert-if-true

=non-empty-string $file

Return values
bool

TRUE on success, FALSE on failure

putConfig()

Puts content in a config file.

public static putConfig(string $file, array<string|int, mixed> $content[, int $inline = 3 ]) : bool
Parameters
$file : string

Path to the file

$content : array<string|int, mixed>

Content for the file

$inline : int = 3

The level where you switch to inline YAML

Tags
psalm-assert-if-true

=non-empty-string $file

Return values
bool

TRUE on success, FALSE on failure

require()

Returns the content of a file.

public static require(string $file) : string
Parameters
$file : string

Path to the file

Tags
throws
rex_exception

throws when the file cannot be read

psalm-assert

non-empty-string $file

Return values
string

Content of the file


        
On this page

Search results