class FileInfo extends SplFileInfo

File info.

Methods

string|null
getMimeType()

Returns the MIME type of the file.

string|null
getMimeEncoding()

Returns the MIME encoding of the file.

string
getHash(string $algorithm = 'sha256', bool $raw = false)

Generates a hash using the contents of the file.

bool
validateHash(string $hash, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided hash and FALSE if not.

string
getHmac(string $key, string $algorithm = 'sha256', bool $raw = false)

Generates a HMAC using the contents of the file.

bool
validateHmac(string $hmac, string $key, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided HMAC and FALSE if not.

Details

at line 29
string|null getMimeType()

Returns the MIME type of the file.

Return Value

string|null

at line 45
string|null getMimeEncoding()

Returns the MIME encoding of the file.

Return Value

string|null

at line 63
string getHash(string $algorithm = 'sha256', bool $raw = false)

Generates a hash using the contents of the file.

Parameters

string $algorithm Hashing algorithm
bool $raw Output raw binary data?

Return Value

string

at line 76
bool validateHash(string $hash, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided hash and FALSE if not.

Parameters

string $hash Hash
string $algorithm Hashing algorithm
bool $raw Is the provided hash raw?

Return Value

bool

at line 89
string getHmac(string $key, string $algorithm = 'sha256', bool $raw = false)

Generates a HMAC using the contents of the file.

Parameters

string $key Shared secret key
string $algorithm Hashing algorithm
bool $raw Output raw binary data?

Return Value

string

at line 103
bool validateHmac(string $hmac, string $key, string $algorithm = 'sha256', bool $raw = false)

Returns TRUE if the file matches the provided HMAC and FALSE if not.

Parameters

string $hmac HMAC
string $key Key
string $algorithm Hashing algorithm
bool $raw Is the provided HMAC raw?

Return Value

bool