Documentation

File extends SplFileInfo
in package

A file in the file system.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

__construct()  : mixed
Constructs a new file from the given path.
getContent()  : string
getMimeType()  : string|null
Returns the mime type of the file.
guessExtension()  : string|null
Returns the extension based on the mime type.
move()  : self
Moves the file to a new location.
getName()  : string
Returns locale independent base name of the given path.
getTargetFile()  : self

Methods

__construct()

Constructs a new file from the given path.

public __construct(string $path[, bool $checkPath = true ]) : mixed
Parameters
$path : string

The path to the file

$checkPath : bool = true

Whether to check the path or not

Tags
throws
FileNotFoundException

If the given path is not a file

Return values
mixed

getContent()

public getContent() : string
Return values
string

getMimeType()

Returns the mime type of the file.

public getMimeType() : string|null

The mime type is guessed using a MimeTypeGuesserInterface instance, which uses finfo_file() then the "file" system binary, depending on which of those are available.

Tags
see
MimeTypes
Return values
string|null

guessExtension()

Returns the extension based on the mime type.

public guessExtension() : string|null

If the mime type is unknown, returns null.

This method uses the mime type as guessed by getMimeType() to guess the file extension.

Tags
see
MimeTypes
see
getMimeType()
Return values
string|null

move()

Moves the file to a new location.

public move(string $directory[, string|null $name = null ]) : self
Parameters
$directory : string
$name : string|null = null
Tags
throws
FileException

if the target file could not be created

Return values
self

getName()

Returns locale independent base name of the given path.

protected getName(string $name) : string
Parameters
$name : string
Return values
string

getTargetFile()

protected getTargetFile(string $directory[, string|null $name = null ]) : self
Parameters
$directory : string
$name : string|null = null
Return values
self

Search results