Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

FileInfo.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\IO\MimeTypeDetector;
8
9 use eZ\Publish\SPI\IO\MimeTypeDetector;
10
11 class FileInfo implements MimeTypeDetector
12 {
18 protected $fileInfo;
19
23 public function __construct()
24 {
25 // Enabled by default since 5.3. Still checking if someone disabled
26 // manually.
27 if (!extension_loaded('fileinfo')) {
28 throw new \RuntimeException('The extension "ext/fileinfo" must be loaded in order for this class to work.');
29 }
30 }
31
32 public function getFromPath($path)
33 {
34 return $this->getFileInfo()->file($path);
35 }
36
37 public function getFromBuffer($path)
38 {
39 return $this->getFileInfo()->buffer($path);
40 }
41
47 protected function getFileInfo()
48 {
49 if (!isset($this->fileInfo)) {
50 $this->fileInfo = new \finfo(FILEINFO_MIME_TYPE);
51 }
52
53 return $this->fileInfo;
54 }
55 }
eZ\Publish\Core\IO\MimeTypeDetector\FileInfo
Definition: FileInfo.php:12
eZ\Publish\Core\IO\MimeTypeDetector\FileInfo\getFromBuffer
getFromBuffer($path)
Returns the MIME type of the data in $buffer.
Definition: FileInfo.php:37
eZ\Publish\Core\IO\MimeTypeDetector\FileInfo\$fileInfo
$fileInfo
Definition: FileInfo.php:18
eZ\Publish\Core\IO\MimeTypeDetector\FileInfo\getFromPath
getFromPath($path)
Returns the MIME type of the file identified by $path.
Definition: FileInfo.php:32
eZ\Publish\Core\IO\MimeTypeDetector\FileInfo\getFileInfo
getFileInfo()
Creates a new (or re-uses) finfo object and returns it.
Definition: FileInfo.php:47
eZ\Publish\Core\IO\MimeTypeDetector\FileInfo\__construct
__construct()
Checks for the required ext/fileinfo.
Definition: FileInfo.php:23
eZ\Publish\SPI\IO\MimeTypeDetector
Definition: MimeTypeDetector.php:10
eZ\Publish\Core\IO\MimeTypeDetector
Definition: FileInfo.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.