class SplFileInfo in Database Sanitize 7
Extends \SplFileInfo to support relative paths.
@author Fabien Potencier <fabien@symfony.com>
Hierarchy
- class \Symfony\Component\Finder\SplFileInfo
- class \Symfony\Component\Finder\SplFileInfo
Expanded class hierarchy of SplFileInfo
1 file declares its use of SplFileInfo
- RecursiveDirectoryIterator.php in vendor/
symfony/ finder/ Iterator/ RecursiveDirectoryIterator.php
File
- vendor/
symfony/ finder/ SplFileInfo.php, line 19
Namespace
Symfony\Component\FinderView source
class SplFileInfo extends \SplFileInfo {
private $relativePath;
private $relativePathname;
/**
* @param string $file The file name
* @param string $relativePath The relative path
* @param string $relativePathname The relative path name
*/
public function __construct($file, $relativePath, $relativePathname) {
parent::__construct($file);
$this->relativePath = $relativePath;
$this->relativePathname = $relativePathname;
}
/**
* Returns the relative path.
*
* This path does not contain the file name.
*
* @return string the relative path
*/
public function getRelativePath() {
return $this->relativePath;
}
/**
* Returns the relative path name.
*
* This path contains the file name.
*
* @return string the relative path name
*/
public function getRelativePathname() {
return $this->relativePathname;
}
/**
* Returns the contents of the file.
*
* @return string the contents of the file
*
* @throws \RuntimeException
*/
public function getContents() {
set_error_handler(function ($type, $msg) use (&$error) {
$error = $msg;
});
$content = file_get_contents($this
->getPathname());
restore_error_handler();
if (false === $content) {
throw new \RuntimeException($error);
}
return $content;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SplFileInfo:: |
private | property |
Overrides SplFileInfo:: |
1 |
SplFileInfo:: |
private | property |
Overrides SplFileInfo:: |
1 |
SplFileInfo:: |
public | function |
Returns the contents of the file. Overrides SplFileInfo:: |
1 |
SplFileInfo:: |
public | function |
Returns the relative path. Overrides SplFileInfo:: |
1 |
SplFileInfo:: |
public | function |
Returns the relative path name. Overrides SplFileInfo:: |
1 |
SplFileInfo:: |
public | function |
Overrides SplFileInfo:: |
1 |