PHP Class Symfony\Component\HttpFoundation\File\File

Author: Bernhard Schussek ([email protected])
Inheritance: extends SplFileInfo
Show file Open project: pmjones/php-framework-benchmarks Class Usage Examples

Public Methods

Method Description
__construct ( string $path, boolean $checkPath = true ) Constructs a new file from the given path.
getExtension ( ) : string Returns the extension of the file.
getMimeType ( ) : string | null Returns the mime type of the file.
guessExtension ( ) : string | null Returns the extension based on the mime type.
move ( string $directory, string $name = null ) : File Moves the file to a new location.

Method Details

__construct() public method

Constructs a new file from the given path.
public __construct ( string $path, boolean $checkPath = true )
$path string The path to the file
$checkPath boolean Whether to check the path or not

getExtension() public method

\SplFileInfo::getExtension() is not available before PHP 5.3.6
public getExtension ( ) : string
return string The extension

getMimeType() public method

The mime type is guessed using the functions finfo(), mime_content_type() and the system binary "file" (in this order), depending on which of those is available on the current operating system.
public getMimeType ( ) : string | null
return string | null The guessed mime type (i.e. "application/pdf")

guessExtension() public method

If the mime type is unknown, returns null.
public guessExtension ( ) : string | null
return string | null The guessed extension or null if it cannot be guessed

move() public method

Moves the file to a new location.
public move ( string $directory, string $name = null ) : File
$directory string The destination folder
$name string The new file name
return File A File object representing the new file