21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
* @author Bernhard Schussek <bschussek@gmail.com>
class File extends \SplFileInfo
* Constructs a new file from the given path.
* @param string $path The path to the file
* @param bool $checkPath Whether to check the path or not
* @throws FileNotFoundException If the given path is not a file
public function __construct(string $path, bool $checkPath = true)
if ($checkPath && !is_file($path)) {
throw new FileNotFoundException($path);
* Returns the extension based on the mime type.
* If the mime type is unknown, returns null.
* This method uses the mime type as guessed by getMimeType()